void glcd_test_circles(void) { uint8_t x,y,radius; while (1) { uint8_t i; glcd_clear(); // generate random(ish) position on display x = rand() % GLCD_LCD_WIDTH; y = rand() % GLCD_LCD_HEIGHT; radius = rand() % 50; //x = 70; y=25; radius=50; // for debugging // fill circle with black for (i=0; i<=radius; i++) { glcd_fill_circle(x,y,i,BLACK); glcd_write(); delay_ms(2); } // fill the same circle above but with white for (i=0; i<=radius; i++) { glcd_fill_circle(x,y,i,WHITE); glcd_write(); delay_ms(1); } DEMO_RETURN(); } }
void glcd_test_counter_and_graph(void) { uint8_t count = 0; char string[8] = ""; while(1) { glcd_clear_buffer(); //glcd_tiny_set_font(Font5x7,5,7,32,127); //glcd_draw_string_xy(0,40,(char *)utoa(count,string,10)); glcd_set_font(Liberation_Sans15x21_Numbers,15,21,46,57); //glcd_set_font(Liberation_Sans27x36_Numbers,27,36,46,57); //glcd_set_font(Bebas_Neue20x36_Bold_Numbers,20,36,46,57); //glcd_set_font(Bebas_Neue18x36_Numbers,18,36,46,57); //glcd_set_font(HelveticaNeueLT_Com_57_Cn23x35_Numbers,23,35,46,57); // commercial font - not for public distribution sprintf(string,"%d",count); glcd_draw_string_xy(0,0,string); glcd_bar_graph_horizontal(10,38,30,6,count*4); glcd_bar_graph_vertical(70,0,8,30,count*2); glcd_write(); count += 1; DEMO_RETURN(); } }
void glcd_draw_bitmap(const unsigned char *data) { #if 0 /* Testing purposes only: Writing to the LCD right away (not for AVR) */ /* Normally, we do not do this, we just write to the screen buffer */ uint8_t *original_buffer; /* Save the location of original screen buffer */ original_buffer = glcd_buffer_selected; /* Use bitmap location as screen buffer (this won't work when using AVR8 PGM_P) */ glcd_select_screen((uint8_t *)data, glcd_bbox_selected); /* Make sure we write the entre display */ glcd_bbox_refresh(); glcd_write(); /* Restore the screen buffer back to original */ glcd_select_screen(original_buffer, glcd_bbox_selected); #endif /* Copy bitmap data to the screen buffer */ #if defined(GLCD_DEVICE_AVR8) memcpy_P(glcd_buffer_selected, data, (GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8)); #else memcpy(glcd_buffer_selected, data, (GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8)); #endif glcd_bbox_refresh(); }
void glcd_test_bitmap_128x64(void) { glcd_draw_bitmap(bmp_oslogo); glcd_write(); while (1) { DEMO_RETURN(); } }
void glcd_test_hello_world(void) { glcd_tiny_set_font(Font5x7,5,7,32,127); glcd_clear_buffer(); glcd_tiny_draw_string(0,0,"Hello World!"); glcd_write(); while(1) { DEMO_RETURN(); } }
void glcd_test_rectangles(void) { glcd_tiny_set_font(Font5x7,5,7,32,127); glcd_clear_buffer(); glcd_tiny_draw_string(0,0,"RECTANGLE DEMO"); glcd_write(); delay_ms(200); while(1) { glcd_clear(); glcd_draw_rect(0,0,100,50,BLACK); glcd_tiny_draw_string(0,GLCD_NUMBER_OF_BANKS-1,"glcd_draw_rect"); glcd_write(); delay_ms(500); DEMO_RETURN(); glcd_clear(); glcd_tiny_draw_string(0,GLCD_NUMBER_OF_BANKS-1,"glcd_draw_rect_thick"); glcd_write(); glcd_draw_rect_thick(5,5,80,30,3,6,BLACK); glcd_write(); delay_ms(500); DEMO_RETURN(); glcd_draw_rect_thick(0,0,20,20,2,2,BLACK); glcd_write(); delay_ms(500); DEMO_RETURN(); glcd_draw_rect_thick(100,10,20,20,5,5,BLACK); glcd_write(); delay_ms(500); DEMO_RETURN(); glcd_clear(); glcd_tiny_draw_string(0,GLCD_NUMBER_OF_BANKS-1,"glcd_draw_rect_shadow"); glcd_draw_rect_shadow(0,0,45,30,BLACK); glcd_write(); delay_ms(500); DEMO_RETURN(); glcd_draw_rect_shadow(95,5,30,30,BLACK); glcd_write(); delay_ms(500); DEMO_RETURN(); } }
void glcd_test_text_up_down(void) { // moves some text up and down the display uint8_t y; uint8_t max_y; //glcd_set_font(Liberation_Sans11x14_Numbers,11,14,46,57); glcd_set_font(Liberation_Sans15x21_Numbers,15,21,46,57); //glcd_set_font(Liberation_Sans27x36_Numbers,27,36,46,57); //glcd_set_font(Liberation_Sans17x17_Alpha,17,17,46,90); max_y = GLCD_LCD_HEIGHT - font_current.height - 2; // max y start position for draw_string while(1) { // move top to bottom for (y=0; y<max_y; y++) { DEMO_RETURN(); glcd_clear_buffer(); glcd_draw_string_xy(0,y,"123"); glcd_write(); delay_ms(80); } // move bottom to top for (y=(max_y); y>0; y--) { DEMO_RETURN(); glcd_clear_buffer(); glcd_draw_string_xy(0,y,"456"); glcd_write(); delay_ms(80); } } }
void glcd_test_glcdutils(void) { uint16_t count = 0; char string[8] = ""; while(1) { glcd_clear_buffer(); /* Set the font */ glcd_font(font_Earthbound_12x19_48to57,12,19,48,57,GLCD_UTILS); sprintf(string,"%d",count); glcd_draw_string_xy(0,0,string); glcd_write(); count += 1; DEMO_RETURN(); } }
void glcd_test_scrolling_graph(void) { glcd_clear(); glcd_write(); while(1) { uint16_t n; for (n=0; n<=255; n += 20) { glcd_scrolling_bar_graph(0,0,50,50,n); glcd_scrolling_bar_graph(60,0,50,30,n); glcd_scrolling_bar_graph(60,35,60,20,n); DEMO_RETURN(); } for (n=0; n<=255; n += 20) { glcd_scrolling_bar_graph(0,0,50,50,255-n); glcd_scrolling_bar_graph(60,0,50,30,n); glcd_scrolling_bar_graph(60,35,60,20,n); DEMO_RETURN(); } } }
void glcd_tempdata_writer(char Tempdata){ //function that writes to the LCD glcd_tiny_set_font(Font5x7,5,7,32,127); glcd_clear_buffer(); glcd_tiny_draw_string(10,10,"Testing"); glcd_write(); }
void glcd_clear(void) { memset(glcd_buffer_selected, 0x00, GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8); glcd_update_bbox(0,0,GLCD_LCD_WIDTH - 1,GLCD_LCD_HEIGHT - 1); glcd_write(); }
int main() { int noteBuffer[SONG_SIZE]; int accidentals[SONG_SIZE]; int octaveBuffer[SONG_SIZE]; memcpy(noteBuffer, rom_notes, SONG_SIZE*sizeof(int)); memcpy(accidentals, rom_accidentals, SONG_SIZE*sizeof(int)); memcpy(octaveBuffer, rom_octaves, SONG_SIZE*sizeof(int)); const int buf_size = SONG_SIZE; //uint8 selected; initHardware(); int start = 0; while (1) { //glcd_clear(); glcd_tiny_set_font(Font5x7,5,7,32,127); update_notes(noteBuffer, accidentals, octaveBuffer, start, buf_size); if (start > 0) { glcd_draw_string_xy(13*6,0,"^"); } if (start+4 < buf_size) { glcd_draw_string_xy(13*6,5*8,"v"); } glcd_draw_char_xy(13*6,1*8,(start/4+1)/100%10+'0'); glcd_draw_char_xy(13*6,2*8,(start/4+1)/10%10+'0'); glcd_draw_char_xy(13*6,3*8,(start/4+1)%10+'0'); glcd_write(); /* start+=4; if (start > 24) start = 0; */ int reading = 0; not_scroll: reading = Keypad_1_GetButton(); switch (reading) { case 7: if (start+4 < buf_size) start+=4; break; case 15: if (start > 0) start-=4; break; case 3: play_song(noteBuffer, accidentals, octaveBuffer, buf_size); break; case 0: for (int i = 0; i < 4; ++i) { glcd_invert_area(i*18, 0, 6, 8); glcd_write(); CyDelay(200); int button = 7; while (button > 6) { button = keycode_to_note[Keypad_1_GetButton()]; } noteBuffer[start+i] = button; update_notes(noteBuffer, accidentals, octaveBuffer, start, buf_size); glcd_invert_area(i*18+6, 0, 6, 8); glcd_write(); CyDelay(200); button = 2; while (button > 1) { button = keycode_to_accidental[Keypad_1_GetButton()]; if (button == 99) goto cancel_edit; } accidentals[start+i] = button; update_notes(noteBuffer, accidentals, octaveBuffer, start, buf_size); glcd_invert_area(i*18+12, 0, 6, 8); glcd_write(); CyDelay(200); button = 10; while (button > 9) { button = keycode_to_octave[Keypad_1_GetButton()]; if (button == 99) goto cancel_edit; } octaveBuffer[start+i] = button; update_notes(noteBuffer, accidentals, octaveBuffer, start, buf_size); } cancel_edit: break; case 1: glcd_clear(); glcd_draw_string_xy(0,0,"Saving..."); glcd_write(); int fail = 0; fail += CYRET_SUCCESS!=Em_EEPROM_Write((void*)noteBuffer, (void*)rom_notes, SONG_SIZE*sizeof(int)); fail += CYRET_SUCCESS!=Em_EEPROM_Write((void*)accidentals, (void*)rom_accidentals, SONG_SIZE*sizeof(int)); fail += CYRET_SUCCESS!=Em_EEPROM_Write((void*)octaveBuffer, (void*)rom_octaves, SONG_SIZE*sizeof(int)); if (fail) { glcd_draw_string_xy(0,8,"Failed!"); glcd_write(); CyDelay(1000); } else { glcd_draw_string_xy(0,8,"Success!"); glcd_write(); CyDelay(300); } break; default: goto not_scroll; } CyDelay(50); } }