; ; basic test code for leoprogrammable board ; shows how to use the "leo_picbasic_library.bas" code. ; copyright (c) 2006 Leo Villareal ; author: jesse lackey, jesse@celestialaudio.com ; ; Version 1.0: august 23 2006 ; NUM_DMX_CHANNELS CON 16 goto main INCLUDE "leo_picbasic_library.bas" ; ; variables ; loopcount8 var byte main: ; init everything. gosub LIB_init_leoprogrammable loopcount8= 0 loop: ; read stuff gosub LIB_read_pots gosub LIB_read_bcd ; output chase on transistors ; this sets g_transistors to have a single "1" in the bit field "loopcount8": lookup2 loopcount8,[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768],g_transistors gosub LIB_set_transistors ; pwm on transistors 14 & 15 g_pwm_transistor14= loopcount8 * 4 gosub LIB_set_transistor14_pwm g_pwm_transistor15= loopcount8 * 4 gosub LIB_set_transistor15_pwm ; output chase on DMX. clear the last channel, set this one to max. if loopcount8 = 0 then g_dmx_data[15] = 0 ; we wrapped around, last channel was #15 else g_dmx_data[loopcount8 - 1] = 0 endif g_dmx_data[loopcount8]= 255; gosub LIB_dmx_out ; debugging printf ; mode 32 is 19200 driven "true", and the 13,10 at the end is cr/lf serout2 bitbang_serial_out_pin,32,["loop ",#loopcount8,": "] serout2 bitbang_serial_out_pin,32,["pb1: ",#pushbutton_1," pb2: ",#pushbutton_2] serout2 bitbang_serial_out_pin,32,[" dip2: ",#dipswitch_2," dip3: ",#dipswitch_3," dip4: ",#dipswitch_4] serout2 bitbang_serial_out_pin,32,[" bcd: ",#g_bcd] serout2 bitbang_serial_out_pin,32,[" pot1: ",#g_pot1," pot2: ",#g_pot2] ; print out a random number from 1 to 10 inclusive g_randMin= 1 g_randMax= 10 gosub LIB_get_rand_minmax serout2 bitbang_serial_out_pin,32,[" rand: ",#g_randOut,13,10] ; 13,10 is cr/lf ; on to next in 16 steps loopcount8= loopcount8 + 1 if loopcount8 = 16 then loopcount8= 0 ; delay according to pot#1 position gosub LIB_set_led_green Pause g_pot1 / 3 gosub LIB_set_led_red Pause g_pot1 / 3 gosub LIB_set_led_off Pause g_pot1 / 3 Goto loop ' Go back to loop forever End