;********************************************************************************* ; gpcardisplay-0v3.bas GpCarDisplay board test ; Louise@RotaryRacer, Terry@RotaryRacer ;********************************************************************************* ; ; This drivers the LED's and reads the switches. The LCD is writen to directly from the speed controller ; This assumes a GpCarDisplay LCD display ; ; For: PICAXE-20X2 ; ; Pins are: ; C.0 Switch0 ; C.1 Switch1 ; C.6 Switch2 ; C.5 Switch3 ; C.4 Switch4 ; C.3 GpSpeed1 ; C.2 GpSpeed0 ; B.4 Led0 ; B.3 Led1 ; B.2 Led2 ; B.1 Led3 ; B.0 Led4 ; B.7 I2c_Clk ; B.5 I2c_Dat ; C.7 LcdReset ; ; Symbols for pin names and variables symbol pinLed0 = B.4 ; The LED0 pin symbol pinLed1 = B.3 ; The LED1 pin symbol pinLed2 = B.2 ; The LED2 pin symbol pinLed3 = B.1 ; The LED3 pin symbol pinSwitch0 = pinC.4 ; The Switch0 pin symbol pinSwitch1 = pinC.0 ; The Switch1 pin symbol pinSwitch2 = pinC.5 ; The Switch2 pin symbol pinLcdReset = C.7 ; The LCD reset pin init: ; setfreq M8 ; let adcsetup = %000000000001111 ; Initialises ADC inputs ; Reset the LCD low pinLcdReset pause 10 high pinLcdReset pause 100 sertxd ("Started: ok", 13, 10) ; goto testLoop ;hi2csetup i2cslave, $10, i2cslow, i2cbyte hi2csetup i2cslave, $10 mainLoop: ; Set LED's from I2C Register 0 ptr = 0; b0 = @ptr if bit0 = 1 then high pinLed0 else low pinLed0 end if if bit1 = 1 then high pinLed1 else low pinLed1 end if if bit2 = 1 then high pinLed2 else low pinLed2 end if if bit3 = 1 then high pinLed3 else low pinLed3 end if ; Set I2C Register 1 from switches if pinSwitch0 = 1 then high bit8 else low bit8 end if if pinSwitch1 = 1 then high bit9 else low bit9 end if if pinSwitch2 = 1 then high bit10 else low bit10 end if ptr = 1; @ptr = b1 goto mainLoop testLoop: if pinSwitch0 = 1 then high pinLed0 high pinLed1 else low pinLed0; low pinLed1; end if goto testLoop test1Loop: pause 1000 toggle pinLed1 pause 2000 toggle pinLed2 pause 3000 goto test1Loop