In SX Microcontrollers, SX/B Compiler and SX-Key Tool, tdg8934 wrote: Yes. I saw that the PAUSE 1 was missing too. I also added a MS_DELAY 100 between the FOR NEXT looping to see it slow down a bit. I noticed that it starts with some RED lines being drawn in up/down and then if I remember right some other colors full flashing like yellow (redgreen). This makes sense because you are executing other messages (Msg2, Msg3) that their characters are not 8x8 (like A, B and C are in Msg1). So the first Msg1 has red for a color and I see some lines being drawn but just wrong display for what should be A B C. [code] 'Use: SEND_MSG MsgAddr, color (0-6) DISPLAY_MSG: tmpW2 = __WPARAM12 ' pass address of message to print; tmpW1 is used in other subs color = __PARAM3 ' entire message will be one color, but you can play with this I'm sure Setup_Led_Driver: LOW ChipSel DELAY_MS 1 ' delay following spec sheet for driver Read_Char: READINC tmpW2, char ' read char from string... IF char = 0 THEN Chars_Done ' end of string? done... 'now, you've got a char, you need to point READ to 'to that 8 byte character map and read in each row of bits, 'convert each bit to byte with color, send it 'but it's FIRST IN, FIRST OUT to the shift register Map_Char: tmpW3 = char - 32 'subtract 32 so 0 = space 'you could do other trickery here to get form feed chars, case sensitivity, etc. tmpW3 = tmpW3 * 8 'it's the charactuer "number" * 8 bytes 'now some trickery is needed to "mask" the bit of the pixel, so you can add color and create a byte... Parse_Char: FOR tmpB5 = 0 TO 7 ' loop through rows, top to bottom READINC ASCII_Set + tmpW3, tmpB2 'read first row of pixels bits ("bitmap") into tmpB2, tmpW3 will increment on each pass FOR tmpB3 = 0 TO 7 ' unless you mirror image your charMaps, you need to send pixels HSB to MSB, hence mask rotates right tmpB4 = %1000_0000 >> tmpB5 'bit mask for this pixel remember it's just a BIT tmpB4 = tmpB2 & tmpB4 'mask with row and save to mask variable space IF tmpB4 <> 0 THEN 'pixel on? -- set to 1 and add color tmpB4 = 1 + color ENDIF 'whew, now you've got a byte with color/on/off ready to go to top left shift register 'so send it SHIFTOUT DataIn, Clock, MSBFIRST, tmpB4 NEXT ' next pixel this row, from LEFT TO RIGHT, not right to left [b]DELAY_MS 100[/b] NEXT 'next row this char Next_Char: GOTO Read_Char Chars_Done: ' latch it and pause!!! [b]DELAY_MS 1 [/b] HIGH ChipSel Msg_Done: RETURN How about using JonnyMac's BIT routine too (if needed): This helped when converting your BS2 DoChar routine for use on the SX/B. [code] ' Use: value = BITVAL someVal, position ' -- "someVal" can be a byte or word FUNC BITVAL IF __PARAMCNT = 2 THEN ' byte passed? tmpW1 = __PARAM1 ' get byte value temp1 = __PARAM2 ' get bit position ELSE ' word passed tmpW1 = __WPARAM12 ' word was passed temp1 = __PARAM3 ' get bit position ENDIF temp2 = 0 ' assume cleared IF temp1 >= 0 THEN ' position value legal? IF temp1 <= 15 THEN tmpW2 = 1 << temp1 ' create bit mask tmpW2 = tmpW2 & tmpW1 ' clear other bits IF tmpW2 > 0 THEN ' if not zero temp2 = 1 ' bit was 1 ENDIF ENDIF ENDIF RETURN temp2 ENDFUNC doChar: LOW ChipSel 'get ready for SPI PAUSE 1 FOR rows = 0 TO 7 'loop through rows pixels = buf(rows) FOR cols = 0 TO 7 'loop cols and make a pixel byte value = BITVAL pixels, cols value = value * Color SHIFTOUT DataIn, Clock, MSBFIRST, value 'if bit for this col/row is 1, then color gets you 1-7 if "on" 'Un-comment to have every LED pixel random 'RANDOM seed 'Rand_no = seed // 7 + 1 'color = Rand_no NEXT NEXT 'Un-comment to have every letter random 'RANDOM temp1 ' 'temp2 = temp1 // 7 'temp2 = temp2 + 1 'color = temp2 RANDOM seed color = seed // 7 color = color + 1 'Hold down on keypad for random color cycling PAUSE 1 HIGH ChipSel 'latch it RETURN [/code] See attached program using these. It uses a 4x4 keypad and lets the user hit the button to display 1-9,0,A-F on the display and it works well. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=225777#m226543 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)