News:

Let's find out together what makes a PIC Tick!

Main Menu

LCD Images

Started by pjdenyer, Feb 28, 2021, 03:58 PM

Previous topic - Next topic

pjdenyer

Hi, I a have create a graphic library for the SSD1963 graphics controller and I am currently working with images, it is my intention to put the images into EEPROM and read them from there as they are so large, however in the mean time I have them in DIM AS Code. Can some suggest away of creating a list of labels, i.e. Image1, Image2, etc where I can use CPTR16++ to access them.
Also, any help on using DMA to go from SPI(EEPROM) to 16bit Port.

top204

The address' of flash memory tables can be stored in an array, and the elements of the array can be accessed to get the address of each flash memory table holding the image data. For example:

'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' Read from different flash memory tables using an array to hold the the address' of them
' Written for the Proton8 BASIC compiler by Les Johnson
'
    Device = 18F25K20
    Declare Xtal = 16  
'
' Setup USART1
'
    Declare Hserial1_Baud = 9600                            ' Setup the Baud rate of USART1
    Declare HRSOut1_Pin = PORTC.6                           ' Setup the pin used for USART1 TX
'
' Create flash memory tables of 8-bit values
'
    Dim Image1 As Code8 = 01, 02, 03, 04, 05, 06, 07, 08, 09, 10
    Dim Image2 As Code8 = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
    Dim Image3 As Code8 = 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
    Dim Image4 As Code8 = 31, 32, 33, 34, 35, 36, 37, 38, 39, 40
    Dim Image5 As Code8 = 41, 42, 43, 44, 45, 46, 47, 48, 49, 50
    Dim Image6 As Code8 = 51, 52, 53, 54, 55, 56, 57, 58, 59, 60
'
' Create some variables
'   
    Dim bImageIndex As Byte                                 ' Holds the index to the array holding the flash memory address'
    Dim bImageData As Byte                                  ' Holds the data read from teh flash memory table
    Dim wImageAddress As Word                               ' Holds the address of the flash memory table
    Dim wDataLoop As Word                                   ' Holds the amount of items to read from teh flash memory table   
    Dim wImageAddressArray[6] As Word Heap                  ' Holds the address' of the flash memory tables
   
'---------------------------------------------------------------------------------
' The main program starts here
' Read and display the data from several flash memory tables
'
Main:

    wImageAddressArray[0] = AddressOf(Image1)               ' \
    wImageAddressArray[1] = AddressOf(Image2)               ' |
    wImageAddressArray[2] = AddressOf(Image3)               ' | Load the array with the address' of the flash memory tables
    wImageAddressArray[3] = AddressOf(Image4)               ' |
    wImageAddressArray[4] = AddressOf(Image5)               ' |
    wImageAddressArray[5] = AddressOf(Image6)               ' /
  
    For bImageIndex = 0 To 5                                ' Create a loop for the amount of elements in the array holding the address of a flash memory table
        wImageAddress = wImageAddressArray[bImageIndex]     ' Get the address of the image from within the array's element
        For wDataLoop = 0 To 9                              ' Create a loop for the amount of items in the flash memory tables
            bImageData = cPtr8(wImageAddress++)             ' Read bytes from the flash memory table based upon the address held in wImageAddress
            HRSOut Dec2 bImageData,","                      ' Transmit the table's data to a serial teminal
        Next                                                ' Close the data read loop
        HRSOut 13                                           ' Transmit a NewLine to the serial terminal
    Next                                                    ' Close the image address loop

On the serial terminal, it shows:

01,02,03,04,05,06,07,08,09,10,
11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,


Which are the elements from each flash memory table read seperately.

If the data in the flash memory tables is 16-bit, use Word variables and Code16 instead of Code8, and the cPtr16 function.

pjdenyer

Hi Les,

My situation is that my current code is

                Case Battery_Level_End + 17
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_1)                              ' Image Width 82 - Image Height 24
                Case Battery_Level_End + 16
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_2)                              ' Image Width 82 - Image Height 23
                Case Battery_Level_End + 15
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_3)                              ' Image Width 82 - Image Height 22
                Case Battery_Level_End + 14
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_4)                              ' Image Width 82 - Image Height 21
                Case Battery_Level_End + 13
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_5)                              ' Image Width 82 - Image Height 20
                Case Battery_Level_End + 12
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_6)                              ' Image Width 82 - Image Height 19
                Case Battery_Level_End + 11
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_7)                              ' Image Width 82 - Image Height 18
                Case Battery_Level_End + 10
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_8)                              ' Image Width 82 - Image Height 17
                Case Battery_Level_End + 9
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_9)                              ' Image Width 82 - Image Height 16
                Case Battery_Level_End + 8
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_10)                             ' Image Width 82 - Image Height 15
                Case Battery_Level_End + 7
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_11)                             ' Image Width 82 - Image Height 14
                Case Battery_Level_End + 6
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_12)                             ' Image Width 82 - Image Height 13
                Case Battery_Level_End + 5
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_13)                             ' Image Width 82 - Image Height 12
                Case Battery_Level_End + 4
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_14)                             ' Image Width 82 - Image Height 11
                Case Battery_Level_End + 3
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_15)                             ' Image Width 82 - Image Height 10
                Case Battery_Level_End + 2
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_16)                             ' Image Width 82 - Image Height 9
                Case Battery_Level_End + 1
                    Glcd_wImagePointer = AddressOf(Battery_Gauge_Filler_Top_17)                             ' Image Width 82 - Image Height 8

But I am looking if possible the put it in some sort of table that I can increment a point to point to the next Label, after compiling Address
 

pjdenyer

Hi Les,

What does "Heap" do in the "Dim wImageAddressArray[6] As Word Heap" statement as it is not mentioned in the compiler manual

top204

See page 30 of the current Positron8 compiler manual.

pjdenyer

Hi Les,

I a using Positro16 and hence looked in the Positron16 manual, as Heap is only referenced for Positron8, is it required when using Positron16

top204

When asking a question, it is very important to state some details about the device in question. :-) They are all very different, and it is the compiler that makes them look the same.

The Heap directive has no relevance in Positron16 because the PIC24 and dsPIC33 devices have linear RAM, and the compiler auto arranges the variables within the RAM to suit the 16-bit address requirements of them.

That is why it is not in the Positron16 manual. :-) The Positron16 compiler simply ignores the Heap directive.