Пример #1
0
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();
	}

}
Пример #2
0
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);
		}

	}

}
Пример #3
0
void update_notes(int* notebuf, int* accidentalsbuf, int* octavebuf, int start, int buflen) {
	glcd_clear();
	char line[15];
	for (int i = start; i < ((start+24<buflen)?(start+24):buflen); i+=4) {
		sprintf(line, "%c%c%d%c%c%d%c%c%d%c%c%d",
			(char)(notebuf[i]+'A'), accidental_from_index(accidentalsbuf[i]),
				octavebuf[i],
			(char)(notebuf[i+1]+'A'), accidental_from_index(accidentalsbuf[i+1]),
				octavebuf[i+1],
			(char)(notebuf[i+2]+'A'), accidental_from_index(accidentalsbuf[i+2]),
				octavebuf[i+2],
			(char)(notebuf[i+3]+'A'), accidental_from_index(accidentalsbuf[i+3]),
				octavebuf[i+3]);
		glcd_draw_string_xy(0, (i-start)*2, line);
	}
}
Пример #4
0
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();
	}
}
Пример #5
0
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);
	}
}