X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=betty%2Fbetty.c;h=c2aaa386b291d9421a8890295a26f757a5423b16;hb=71bf7666ce24cd3c07bb16648e0ab231e07be6d8;hp=f2ce2e5fba098487845e8c310c3252c7ca91b999;hpb=90fa4f3eca580f497dd24e9b3afd818d3b1f7054;p=my-code%2Farm.git diff --git a/betty/betty.c b/betty/betty.c index f2ce2e5..c2aaa38 100644 --- a/betty/betty.c +++ b/betty/betty.c @@ -5,9 +5,110 @@ * */ +/* includes */ +#include "betty.h" + +/* + * functions + */ + +#define cc1100_init spi1_init(8,SPI_MASTER,8) + +/* + * main function + */ + int main() { + char announce[]="betty - live from flash at 0x80000000! ;)\r\n"; + t_button button; + u8 contrast; + + /* system init */ + pll_init(); + pin_init(); + ext_mem_init(); + + /* uart init */ + uart0_init(); + + /* display init */ + display_bl_init(); + + /* button init */ + button_init(&button); + button_set_retries(&button,100); + + /* flash init */ + flash_init(); + + /* + * start it ... + */ + + /* pause - seems to not work if running from flash! (?) */ + pause(0xffffff); + + /* display init */ + display_bl_toggle(); + display_init(); + contrast=0x32; + + /* pasue again */ + + /* announce */ + uart0_send_string(announce); + + + while(1) { + pause(0x0fffff); + /* button test! */ + if(button_get_event(&button)) { + //uart0_send_string(announce); + uart0_send_byte(contrast); + switch(button.key[0]) { + case BUTTON_POWER: + display_load_logo(0); + break; + case BUTTON_DOWN: + if(contrast>0x00) + contrast-=1; + DISPLAY_SET_CONTRAST(contrast); + break; + case BUTTON_UP: + if(contrast<0x3f) + contrast+=1; + DISPLAY_SET_CONTRAST(contrast); + break; + case BUTTON_A: + display_fill_screen(DISPLAY_FILL_W); + break; + case BUTTON_B: + display_fill_screen(DISPLAY_FILL_LG); + break; + case BUTTON_C: + display_fill_screen(DISPLAY_FILL_DG); + break; + case BUTTON_D: + display_fill_screen(DISPLAY_FILL_B); + break; + case BUTTON_1: + display_draw_rectangle(20,20,40,40, + DISPLAY_FILL_B, + 0); + break; + case BUTTON_2: + display_draw_rectangle(50,50,40,40, + DISPLAY_FILL_LG, + 0); + break; + default: + display_clear_screen(); + break; + } + } + } return 0; }