Skip to content

Conversation

@LongDirtyAnimAlf
Copy link
Contributor

No description provided.

@LongDirtyAnimAlf
Copy link
Contributor Author

Added some display abstraction.

</SyntaxOptions>
</Parsing>
<CodeGeneration>
<HeapSize Value="8192"/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you removed Heap/StackSize Values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anything particular.
My normal practice is to try to get things running with as little extra settings as possible.
So, its just a way for me to check if things are running without these extra settings.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am too lazy to look this up in details atm but I guess your code will sooner or later crash and burn when those are not properly set. But it may be that some defaults are applied when nothing is set, as said, too lazy to look this up atm.

</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, any specific reason for this? Having Debug Info will not change the size of the deployed code, so why turn DebugInfo off?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, not anything particular.
My normal practice is to try to get things running with as little extra settings as possible.

<Version Value="11"/>
<Target>
<Filename Value="Blinky"/>
<Filename Value="bin/$(TargetCPU)-$(TargetOS)/samc21/$NameOnly($(ProjFile))"/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you did this because you had issues with build.
There are two problems here:
a) As we heavily use defines it is still unsave to do a simple build, better do a rebuild all from time to time
b) If we stay with this we will need a generic way to define the name of the 'samc21' directory because I also need to define the path to the executable for Debugging (Ozone)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No build issues.
I always use a single lpi for multiple targets.
And use "Compile many Modes" to generate all binaries at once.
And use the paths settings to split libraries and binaries for easy comparison.

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Owner

@michael-ring michael-ring Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments here as for the other lpi file, or did I overlook something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct: you did not overlook anything ... ;-)

@@ -27,7 +27,7 @@
{$if defined(SAMD10XMINI)}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

TArduinoPin = record
const
None=-1;
D13= TNativePin.PA14; // just for blinky to work
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the right way to do things. Better define a const LED (and LED0) with value TNativePin.PA14.
You should not 'kill' the ArduinoPins Definition for the sake of making Blinky run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully agreed.
But the current Blinky used this Arduino-pin, and the board itself has no Arduino pins.
Please correct me if I am wrong.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look here:

http://www.microchip.com/DevelopmentTools/ProductDetails/atardadpt-xpro

The shield is a little difficult to find when you do not know what to search for

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha !
Did not know of this adapter-board !
Nice addition.
Surely, the Arduino pin-definitions must be included.

@@ -232,7 +232,9 @@ procedure WaitSYSCTRL;
SYSCTRL_DFLLCTRL_QLDIS; // 1 = Disable quick lock.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -0,0 +1,377 @@
program MBED;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will not yet add this sample as it is looking way too complicated and often does not use concepts of MBF

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is ok for me.
Its just a proof of concept.
If all concepts of MBF are clear and stable, this example can easily be adapted.

@@ -0,0 +1,152 @@
program OLED1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will not merge this example in this form as it is not following mbf concepts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.
That is ok for me.
Its just a proof of concept.


const
{$if defined(has_samd20_xplained_pro) or defined(has_samd21_xplained_pro) or defined(has_samc21_xplained_pro)}
PinLED = LED0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of those definitions will (hopefully) get opsolete when SPI Code is completely implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope so too !

TurnedOn:boolean;
i:byte;

procedure ToggleLed;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is toggling an LED part of this demo code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me (and others), to indicate that the board is still alive and kicking !!

GPIO.PinValue[PinLED] := 1;

Display.InvertScr(false);
Display.ClrScr;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ClrScr and not ClearScreen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClearScreen does not do anything (yet).
ClrScr does clear the screenbuffer, without updating the screen.

Should/must be improved !

Display.Pixel[i,0]:=1;
Display.Present;
end;
for i:=0 to (ScreenSize128x32x1.Height-1) do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make this so complicated? ScreenInfo is a public property of (my) TCustomDisplay, better use this instead...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure !!! :-)
My mistake.

@@ -36,7 +36,6 @@ procedure ClearBit(var Value: longword; const Index: Byte);
lsl r3, r1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -0,0 +1,704 @@
unit MBF.Displays.OLED1Xplained;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will need reworking, it uses up too much memory by defining fonts and some screenbuffer content.
Please check my ssd1963 code, fonts are provided via extra units.
I have also written a (very crude) windows GUI that allows you to convert ttf fonts to pascal fonts.
Please check this site:
https://int10h.org/oldschool-pc-fonts/fontlist/
They have some nice ttf fonts that can be converted to perfectly looking pascal fonts with my tool.
I only need to extend the tool to now also create fonts in format specific to those OLED Displays

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, for sure.
Its just a (working) demo.

Result := Pointer(FScreenBuffer + (Cardinal(Index) shr 3) * Cardinal(FScreenSize.X));
end;

procedure TDisplay.ClrScr;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ClrScr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.
Not enough abstraction yet. Need to be changed.

@@ -0,0 +1,704 @@
unit MBF.Displays.OLED1Xplained;
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, as written in E-Mail we should think about two kinds of Display Units, one with Framebuffer, one without...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A screenbuffer could just be a single pointer.
That is assigned or not.
And used accordingly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem of pxl for microcontrollers was that it is very well designed, which caused huge impacts on performance and filesize.
When we allow both framebuffer/NoFramebuffer in one object my fear is that we increase the codesize a lot by always having framebuffer/non-framebuffer code in one procedure/function.

Whith often only 8 or 16k flash this hurts, when you have seperate implementations the design is compromised but you may be able to run the code on devices with lower specs.

I am not sure if I have written that before, I am dtruggeling with myself here as there is a rich choice of boards with plenty of ram/flash but usually Jeppe and I got requests to create header files for boards with crazy low ram/flash footprint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, you are right.
I will think about it.
Perhaps, a framebuffer object can be injected into a display object abstraction. Too late now. Will think with fresh brains tomorrow !

{$ifdef samc}
while (Self.SYNCBUSY>0) do begin end; // Wait for synchronization
{$endif}
end;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should throw an error when no definition matches, this makes extending mbf a lot easier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure !!

{$ifdef has_adc0}ADC0_BASE : SetBit(MCLK.APBCMASK,MCLK_APBCMASK_ADC0_Pos);{$endif}
{$ifdef has_adc0}ADC1_BASE : SetBit(MCLK.APBCMASK,MCLK_APBCMASK_ADC1_Pos);{$endif}
end;
{$endif}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, create a compliler error when no definition matches

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure !!


const
{$ifdef samd10}
TADCPinsMap : array[TADCPin] of TPinIdentifier=(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to use definitions as done in my SPI code (For example mbf.stm32f4.spi TSPIMOSIPins
The advantage is that you get a choice of all available analog pins in Lazarus which makes coding a lot easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look into it !

{$endif}
{$endif}

{$ifdef has_samd20_xplained_pro}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

result:=GetBit(FSerCom.PSerComRegisters^.SPI.INTFLAG,SERCOM_SPI_INTFLAG_RXC_Pos);
end;

procedure TSPI_Registers.WriteSingle(aData:word);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we will have to clean up Procedures for Write on SPI, I think a good approach is to use typesafe implementations and a generic pointer implementation as a fallback. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% agreed.

TicksPerMillisecond := GetSysTickClockFrequency div 1000;

{$if defined(CPUARM)}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way that this can get moved to SystemCore.SAMCD as it is SAMCD specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure. I do not see any problems with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants