void refresh_lcd(int adc_value) { int stringct[20]; int x2 = 60*cos((adc_value*2*3.1416/4095)+3.1416/2); int y2 = 60*sin((adc_value*2*3.1416/4095)+3.1416/2); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_line(x,y,x+x_old,y+y_old); ili93xx_draw_filled_rectangle(0,260,240,300); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_circle(120,160,50); sprintf(stringct,"RV1 = %d Ohms",adc_value*10000/4095); ili93xx_draw_string(40, 280, stringct); if(adc_value == 4095) { ili93xx_set_foreground_color(COLOR_RED); } else { ili93xx_set_foreground_color(COLOR_BLACK); } y_old = y2; x_old =x2; ili93xx_draw_line(x,y,x+x2,y+y2); }
void refresh_lcd(int text, int init) { ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0,init-5,240,init+15); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(50, init, text); }
/** * \brief ADC interrupt handler. */ void ADC_Handler(void) { uint32_t tmp; uint32_t status ; status = adc_get_status(ADC); /* Checa se a interrupção é devido ao canal 5 */ static float rad_antes = 0; if ((status & ADC_ISR_EOC5)) { tmp = adc_get_channel_value(ADC, ADC_POT_CHANNEL); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(9, 39, ILI93XX_LCD_WIDTH,55); v=3.3*((float)tmp)/4095.0; rad=2*pi*((float)tmp)/4095.0; ili93xx_draw_line(120,160,120+54*arm_cos_f32(rad_antes),160+54*arm_sin_f32(rad_antes)); ili93xx_set_foreground_color(COLOR_BLACK); sprintf(vet, "Tensao: %f", v); ili93xx_draw_string(10, 40, vet); ili93xx_draw_line(120,160,120+54*arm_cos_f32(rad),160+54*arm_sin_f32(rad)); rad_antes = rad; } }
static void Button2_Handler(uint32_t id, uint32_t mask) { sprintf(vet, "Contador: %d", --num); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(10, 119, ILI93XX_LCD_WIDTH,150); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(10, 120, vet); }
void atualiza_amp(uint32_t val){ ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(125,8,200,40); ili93xx_set_foreground_color(COLOR_BLACK); char buffer[10]; snprintf(buffer, 10, "%d", val); ili93xx_draw_string(130, 10, (uint8_t *)buffer); }
/** * Handle Interrupcao botao 2. */ static void Button2_Handler(uint32_t id, uint32_t mask) { ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(125,150,180,190); ili93xx_set_foreground_color(COLOR_BLACK); sprintf(s_cont1, "Contador %d", cnt); ili93xx_draw_string(20,160, s_cont1); cnt--; }
void init_tela() { ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(10, 20, (uint8_t *)"Victor"); ili93xx_draw_string(10, 40, (uint8_t *)"Kaio"); ili93xx_draw_string(10, 60, (uint8_t *)"Rafael"); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_filled_rectangle(0,145,240,155); ili93xx_draw_filled_rectangle(0,165,240,175); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_filled_rectangle(90,260,150,275); ili93xx_set_foreground_color(COLOR_RED); ili93xx_draw_filled_rectangle(90,275,150,290); ili93xx_set_foreground_color(COLOR_YELLOW); ili93xx_draw_filled_rectangle(90,290,150,305); }
/** Desenha um retângulo em cima do valor anterior do contador e sobrescreve o novo valor. */ void atualiza_contador(){ //Limpa a tela com um retângulo branco ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(125,100,200,170); ili93xx_set_foreground_color(COLOR_BLACK); char buffer[10]; snprintf(buffer, 10, "%d", counter); ili93xx_draw_string(130, 110, (uint8_t *)buffer); }
void atualiza_variavel() { ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(50,100,200,170); ili93xx_set_foreground_color(COLOR_BLACK); if (isAmp) { ili93xx_draw_string(60, 110, (uint8_t *) "Amplitude"); } else { ili93xx_draw_string(60, 110, (uint8_t *) "Frequencia"); } }
void TC0_Handler(void) { static b = 0; volatile uint32_t ul_dummy; ul_dummy = tc_get_status(TC0,0); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(10,120, (uint8_t *)"Contador:"); sprintf(vet, "Timer: %d", b); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(119, 299, ILI93XX_LCD_WIDTH,319); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(120, 300, vet); b++; }
void configure_LCD(){ /** Enable peripheral clock */ pmc_enable_periph_clk(ID_SMC); /** Configure SMC interface for Lcd */ smc_set_setup_timing(SMC, ILI93XX_LCD_CS, SMC_SETUP_NWE_SETUP(2) | SMC_SETUP_NCS_WR_SETUP(2) | SMC_SETUP_NRD_SETUP(2) | SMC_SETUP_NCS_RD_SETUP(2)); smc_set_pulse_timing(SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE(4) | SMC_PULSE_NCS_WR_PULSE(4) | SMC_PULSE_NRD_PULSE(10) | SMC_PULSE_NCS_RD_PULSE(10)); smc_set_cycle_timing(SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE(10) | SMC_CYCLE_NRD_CYCLE(22)); #if ((!defined(SAM4S)) && (!defined(SAM4E))) smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE | SMC_MODE_DBW_8_BIT); #else smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE); #endif /** Initialize display parameter */ g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH; g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT; g_ili93xx_display_opt.foreground_color = COLOR_BLACK; g_ili93xx_display_opt.background_color = COLOR_WHITE; /** Switch off backlight */ aat31xx_disable_backlight(); /** Initialize LCD */ ili93xx_init(&g_ili93xx_display_opt); /** Set backlight level */ aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); /** Turn on LCD */ ili93xx_display_on(); ili93xx_set_cursor_position(0, 0); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_circle(120, 160, 40); ili93xx_draw_line(120, 160, 60, 160); ili93xx_draw_line(120, 160, 120, 100); ili93xx_draw_line(120, 160, 180, 160); }
/** Desenha um retângulo em cima do valor anterior do contador do tempo e sobrescreve o novo valor. Separa o contador em minutos e segundos também. */ void atualiza_tempo(){ //limpa a tela com branco ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(130,280,ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); int seg = tempo % 60; int min = tempo / 60; char buffer[10]; snprintf(buffer, 10, "%02d:%02d", min, seg); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(140, 300, (uint8_t *)buffer); }
/** * Interrupt handler for TC0 interrupt. */ void TC0_Handler(void) { volatile uint32_t ul_dummy; /**************************************************************** * Devemos indicar ao TC que a interrupção foi satisfeita. ******************************************************************/ ul_dummy = tc_get_status(TC0,0); /* Avoid compiler warning */ UNUSED(ul_dummy); sprintf(s_cont1, "Timer %d", timer); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(90,190,180,220); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(20,200, s_cont1); timer ++; }
/** * \brief GFX task core function. * * \param pvParameters Junk parameter. */ static void gfx_task(void *pvParameters) { uint32_t blink = 0; /* Get rid of this compiler warning. */ pvParameters = pvParameters; /* Enable display, backlight and print ATMEL logo. */ ili93xx_set_cursor_position(0,0); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); gfx_draw_bmpfile(logo_atmel_bmp); ili93xx_display_on(); for (uint32_t i = AAT31XX_MIN_BACKLIGHT_LEVEL; i <= AAT31XX_MAX_BACKLIGHT_LEVEL; ++i) { aat31xx_set_backlight(i); vTaskDelay(40); } vTaskDelay(presentation_delay); /* Draw IP config menu. */ ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); #if (IP_SELECTION == IP_FIXED) /* Static IP button selected. */ /* Button 1. */ ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(20,70,220,130); ili93xx_set_foreground_color(0xE4E4E4u); ili93xx_draw_rectangle(22,72,222,132); ili93xx_set_foreground_color(COLOR_LIGHTGREY); ili93xx_draw_filled_rectangle(21,71,221,131); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(92, 91, (uint8_t *)"Static"); /* Button 2. */ ili93xx_set_foreground_color(0xE4E4E4u); ili93xx_draw_rectangle(20,170,220,230); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(22,172,222,232); ili93xx_set_foreground_color(COLOR_LIGHTGREY); ili93xx_draw_filled_rectangle(21,171,221,231); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(102, 191, (uint8_t *)"DHCP"); #else /* DHCP IP button selected. */ /* Button 1. */ ili93xx_set_foreground_color(0xE4E4E4u); ili93xx_draw_rectangle(20,70,220,130); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(22,72,222,132); ili93xx_set_foreground_color(COLOR_LIGHTGREY); ili93xx_draw_filled_rectangle(21,71,221,131); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(92, 91, (uint8_t *)"Static"); /* Button 2. */ ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(20,170,220,230); ili93xx_set_foreground_color(0xE4E4E4u); ili93xx_draw_rectangle(22,172,222,232); ili93xx_set_foreground_color(COLOR_LIGHTGREY); ili93xx_draw_filled_rectangle(21,171,221,231); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(102, 191, (uint8_t *)"DHCP"); #endif ili93xx_draw_string(22, 30, (uint8_t *)"IP Configuration"); ili93xx_draw_string(20, 260, (uint8_t *)"Assigned IP:"); ili93xx_draw_rectangle(20,280,220,310); /* Bring up the ethernet interface & initializes timer0, channel0 */ ili93xx_draw_string(30, 290, (uint8_t *)"Please wait..."); init_ethernet(); app_hold = 0; /* Show configured IP and unlock all other waiting tasks. */ ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(20,280,220,310); ili93xx_draw_filled_rectangle(0,0,240,60); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(20,280,220,310); ili93xx_draw_string(30, 290, (uint8_t const*)g_c_ipconfig); /* GFX task Loop. */ while (1) { /* Make HTTP text to blink to show GFX task activity. */ if (blink == 0) { ili93xx_draw_string(5, 30, (uint8_t *)"HTTP server running!"); blink = 1; } else { ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0,0,240,60); ili93xx_set_foreground_color(COLOR_BLACK); blink = 0; } /* Sleep to reach the expected blink rate. */ /* Leave some CPU time for other tasks. */ vTaskDelay(gfx_refresh_rate); } }
*/ int main(void) { sysclk_init(); board_init(); /** Initialize debug console */ configure_console(); /** Configura o timer */ configure_tc(); /* Configura os botões */ configure_buttons(); /** Enable peripheral clock */ pmc_enable_periph_clk(ID_SMC); /** Configure SMC interface for Lcd */ smc_set_setup_timing(SMC, ILI93XX_LCD_CS, SMC_SETUP_NWE_SETUP(2) | SMC_SETUP_NCS_WR_SETUP(2) | SMC_SETUP_NRD_SETUP(2) | SMC_SETUP_NCS_RD_SETUP(2)); smc_set_pulse_timing(SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE(4) | SMC_PULSE_NCS_WR_PULSE(4) | SMC_PULSE_NRD_PULSE(10) | SMC_PULSE_NCS_RD_PULSE(10)); smc_set_cycle_timing(SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE(10) | SMC_CYCLE_NRD_CYCLE(22)); #if ((!defined(SAM4S)) && (!defined(SAM4E))) smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE | SMC_MODE_DBW_8_BIT); #else smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE); #endif /** Initialize display parameter */ g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH; g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT; g_ili93xx_display_opt.foreground_color = COLOR_BLACK; g_ili93xx_display_opt.background_color = COLOR_WHITE; /** Switch off backlight */ aat31xx_disable_backlight(); /** Initialize LCD */ ili93xx_init(&g_ili93xx_display_opt); /** Set backlight level */ aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); /** Turn on LCD */ ili93xx_display_on(); ili93xx_set_cursor_position(0, 0); /** Draw text, image and basic shapes on the LCD */ ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(80, 10, (uint8_t *)"13 - LCD"); ili93xx_draw_string(10, 40, (uint8_t *)"Andre"); ili93xx_draw_string(10, 60, (uint8_t *)"Thales"); ili93xx_draw_string(10, 80, (uint8_t *)"Tete"); ili93xx_set_foreground_color(COLOR_ORANGE); ili93xx_draw_filled_rectangle(0, 100, ILI93XX_LCD_WIDTH,105); ili93xx_set_foreground_color(COLOR_GREEN); ili93xx_draw_filled_rectangle(0, 106, ILI93XX_LCD_WIDTH,111); while (1) { /* Entra em modo sleep */ pmc_sleep(SAM_PM_SMODE_SLEEP_WFI); }
/** * \brief Application entry point for smc_lcd example. * * \return Unused (ANSI-C compatibility). */ int main(void) { sysclk_init(); board_init(); /** Initialize debug console */ configure_console(); /** Enable peripheral clock */ pmc_enable_periph_clk(ID_SMC); /** Configure SMC interface for Lcd */ smc_set_setup_timing(SMC, ILI93XX_LCD_CS, SMC_SETUP_NWE_SETUP(2) | SMC_SETUP_NCS_WR_SETUP(2) | SMC_SETUP_NRD_SETUP(2) | SMC_SETUP_NCS_RD_SETUP(2)); smc_set_pulse_timing(SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE(4) | SMC_PULSE_NCS_WR_PULSE(4) | SMC_PULSE_NRD_PULSE(10) | SMC_PULSE_NCS_RD_PULSE(10)); smc_set_cycle_timing(SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE(10) | SMC_CYCLE_NRD_CYCLE(22)); #if ((!defined(SAM4S)) && (!defined(SAM4E))) smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE | SMC_MODE_DBW_8_BIT); #else smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE); #endif /** Initialize display parameter */ g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH; g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT; g_ili93xx_display_opt.foreground_color = COLOR_BLACK; g_ili93xx_display_opt.background_color = COLOR_WHITE; /** Switch off backlight */ aat31xx_disable_backlight(); /** Initialize LCD */ ili93xx_init(&g_ili93xx_display_opt); /** Set backlight level */ aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); /** Turn on LCD */ ili93xx_display_on(); ili93xx_set_cursor_position(0, 0); /** Draw text, image and basic shapes on the LCD */ ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(10, 20, (uint8_t *)"ili93xx_lcd example"); ili93xx_set_foreground_color(COLOR_RED); ili93xx_draw_circle(60, 160, 40); ili93xx_set_foreground_color(COLOR_GREEN); ili93xx_draw_circle(120, 160, 40); ili93xx_set_foreground_color(COLOR_BLUE); ili93xx_draw_circle(180, 160, 40); ili93xx_set_foreground_color(COLOR_VIOLET); ili93xx_draw_line(0, 0, 240, 320); while (1) { } }
/** * \brief Application entry point for smc_lcd example. * * \return Unused (ANSI-C compatibility). */ int main(void) { sysclk_init(); board_init(); /** Configura os botões, o TC e desabilita o Watchdog Timer. */ configure_buttons(); WDT->WDT_MR = WDT_MR_WDDIS; configure_tc(); /** Initialize debug console */ configure_console(); /** Enable peripheral clock */ pmc_enable_periph_clk(ID_SMC); /** Configure SMC interface for Lcd */ smc_set_setup_timing(SMC, ILI93XX_LCD_CS, SMC_SETUP_NWE_SETUP(2) | SMC_SETUP_NCS_WR_SETUP(2) | SMC_SETUP_NRD_SETUP(2) | SMC_SETUP_NCS_RD_SETUP(2)); smc_set_pulse_timing(SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE(4) | SMC_PULSE_NCS_WR_PULSE(4) | SMC_PULSE_NRD_PULSE(10) | SMC_PULSE_NCS_RD_PULSE(10)); smc_set_cycle_timing(SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE(10) | SMC_CYCLE_NRD_CYCLE(22)); #if ((!defined(SAM4S)) && (!defined(SAM4E))) smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE | SMC_MODE_DBW_8_BIT); #else smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE); #endif /** Initialize display parameter */ g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH; g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT; g_ili93xx_display_opt.foreground_color = COLOR_BLACK; g_ili93xx_display_opt.background_color = COLOR_WHITE; /** Switch off backlight */ aat31xx_disable_backlight(); /** Initialize LCD */ ili93xx_init(&g_ili93xx_display_opt); /** Set backlight level */ aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); /** Turn on LCD */ ili93xx_display_on(); ili93xx_set_cursor_position(0, 0); /** Escreve os nomes no display. */ ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(10, 20, (uint8_t *)"Bruna Tavares"); ili93xx_draw_string(10, 40, (uint8_t *)"Bruno Campos"); ili93xx_draw_string(10, 60, (uint8_t *)"Keneth Yamada"); /** Desenha linha */ ili93xx_set_foreground_color(COLOR_BLUEVIOLET); ili93xx_draw_line(0, 90, 240, 90); /** Escreve contador e tempo no display. */ ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(10, 110, (uint8_t *)"Contador"); ili93xx_draw_string(10, 300, (uint8_t *)"Tempo "); /** Escreve valores iniciais do contador. */ ili93xx_draw_string(130, 110, (uint8_t *)"000"); ili93xx_draw_string(140, 300, (uint8_t *)"00:00"); while (1) { // Coloca o microcontrolador em modo Sleep aguardando interrupções. pmc_sleep(SAM_PM_SMODE_SLEEP_WFI); } }