CPU = 16F872 MHZ = 16 CONFIG 15669 ''''''''''''''''' ' Vars and Cons ' ''''''''''''''''' LCD_Data var byte LCD_Enable con c5 LCD_RS con c4 LCD_Port var portc.nib0 screenposition var byte buffer var byte(20) SER_Tx con B5 SER_Rx con B4 SER_SPEED con i9600 PAUSE_TIME con 300 'time to wait between letters PAUSE_ANIMATE con 30 i var byte Data @0, "MessageLCD v0.2 ",0 Intro con 0 Data @19, " ---Host Offline--- Presumed Asleep ",0 IDLE con 19 ByteIn var byte timeout var byte ASC_B con 66 ASC_C con 67 ASC_F con 70 ASC_P con 80 '''''''' ' Main ' '''''''' Main clear INPUT SER_Rx OUTPUT SER_Tx gosub lcdinit low SER_Tx pause 1000 high SER_Tx pause 1000 LCD_Data = Intro gosub LCDRomMessage mainloop: timeout = (timeout + 1) max 10 if timeout >= 10 then LCD_Data = IDLE gosub LCDRomMessage pause 3000 endif serout SER_Tx, SER_SPEED, ["~"] serin SER_Rx, SER_SPEED, 300, mainloop, [ByteIn] timeout = 0 if ByteIn = "~" then 'command sequence immenent commandloop: serout SER_Tx, SER_SPEED, ["~"] serin SER_Rx, SER_SPEED, 1000, commandloop, [ByteIn] commandreceived: if ByteIn = ASC_C then 'clear LCDwrite LCD_RS\LCD_Enable,LCD_Port, [CLEAR, HOME, SCRCUR, SCRRAM | 20] for i = 0 to 19 buffer(i) = 20 'spaces next screenposition = 20 endif if ByteIn = ASC_F then 'fade gosub REBUFFER for i = 0 to 19 LCDWrite LCD_RS\LCD_Enable, LCD_Port, [SCRRAM | ((i * 7 + 2) // 20), "*"] pause PAUSE_ANIMATE next for i = 0 to 19 LCDWrite LCD_RS\LCD_Enable, LCD_Port, [SCRRAM | ((i * 13 + 2) // 20), " "] pause PAUSE_ANIMATE next gosub clearBuffer LCDWrite LCD_RS\LCD_Enable, LCD_Port, [SCRRAM | 20] screenposition = 20 endif if ByteIn = ASC_P then pause 1000 endif if ByteIn = ASC_B then gosub REBUFFER LCDWrite LCD_RS\LCD_Enable, LCD_Port, [HOME] for i = 0 to 19 LCDWrite LCD_RS\LCD_Enable, LCD_Port, ["#"] pause PAUSE_ANIMATE next LCDWrite LCD_RS\LCD_Enable, LCD_Port, [HOME] for i = 0 to 19 LCDWrite LCD_RS\LCD_Enable, LCD_Port, ["="] pause PAUSE_ANIMATE next LCDWrite LCD_RS\LCD_Enable, LCD_Port, [HOME] for i = 0 to 19 LCDWrite LCD_RS\LCD_Enable, LCD_Port, [" "] pause PAUSE_ANIMATE next endif goto mainloop endif 'have a byte to display gosub drawByteIn pause PAUSE_TIME goto mainloop END ''''''''''''''''''' 'LCD code section ' ''''''''''''''''''' DrawByteIn: LCDwrite LCD_RS\ LCD_Enable, LCD_Port, [ByteIn,SCRLEFT] screenposition = screenposition + 1 for i = 1 to 19 buffer(i-1) = buffer(i) next buffer(19) = ByteIn 'check if need to copy buffer if screenposition > 120 then gosub REBUFFER endif return clearBuffer for i = 0 to 19 buffer(i) = 20 'spaces next return REBUFFER: LCDwrite LCD_RS\LCD_Enable,LCD_Port, [HOME] for i = 0 to 19 LCDwrite LCD_RS\LCD_Enable,LCD_Port, [buffer(i)] next screenposition = 20 return LCDInit pause 2500 'initialize with cursor on LCDwrite LCD_RS\LCD_Enable,LCD_Port, [INITLCD1, INITLCD2, ONELINE, CLEAR, HOME, SCR, SCRRAM | 20] return j var byte LCDRomMessage j = LCD_Data messageloop2 read j, ByteIn j = j + 1 if ByteIn <> 0 then gosub DrawByteIn pause PAUSE_TIME goto messageloop2 endif 'end messageloop2 return