//-----------------------------------------------------------------------------
// Choose Gain
//-----------------------------------------------------------------------------
void choose_gain(void) {
	lcd_clear();
	lcd_print("\nTo set gain press a number, n");
	lcd_print("\nThe gain will be 0.n");
	keypad = read_keypad();
	pause();
	if(keypad != -1)
	{
		lcd_print("\nYou selected 0.%c", keypad);
		ratio = ((keypad - 0x30)/10);
		//ratio needs to be a float or something to hold a decimal
		//doesn't need to be read too often, xdata?
		if(keypad ==0)
		{
			lcd_print("Wire Connection/XBR0 Error");
		}
	}
	
}
Example #2
0
void __attribute__((optimize("O0"))) _menu_render_screen(menu_t *data, uint8_t selected_item){

  uint8_t op = 0;
  lcd_clear();
  FontSelector = f6x8;

  if (data->title){
    print_title(data->title);
  }

  if (data->footer_callback){
    data->footer_callback();
  }

  if (data->render_callback){
    data->render_callback(selected_item);
  }
  lcd_update();
}
Example #3
0
int main() {
	led_redInit();
	led_greenInit();
	led_yellowInit();
	lcd_init();

	adc_init();
	button_init();//latter : button_init(bool);
	while (1) {
//		uint16_t val = adc_read(ADC_JOYSTICK_CH);
//		lcd_setCursor(0,0);
//		lcd_clear();
//		fprintf(lcdout,"%d\n", val);

		if (button_isJoystickPressed())
			led_greenOn();
		else
			led_greenOff();

		if (button_isRotaryPressed())
			led_redOn();
		else
			led_redOff();

		lcd_setCursor(0, 0);
		lcd_clear();
		if (adc_getJoystickDirection() == RIGHT) {
			led_yellowOn();

			fprintf(lcdout, "right\n");
		} else
			led_yellowOff();

		uint16_t temperature = adc_getTemperature();
		//uint16_t temperature = adc_read(ADC_TEMP_CH);
		uint16_t light = adc_read(ADC_LIGHT_CH);
		fprintf(lcdout, "The temperature is %d\n, the light is %d\n",
				temperature, light);
		//slow down the refresh freq of the lcd
		_delay_ms(1000);
	}
}
//===============================================================================
//	Functions
//===============================================================================
//4-bit mode configuration 
void lcd_init()
{
	__delay_ms(30);	//wait for 30ms after power ON for LCD internal controller to initialize itself
	LCD_E = 1;
	//Set lcd to configuration mode
	LCD_RS = 0;		//Selected command register
	__delay_us(5);	//macro from HITECH compiler to generate code to delay for 1 microsecond base on _XTAL_FREQ value
	
	LCD_DATA = (LCD_DATA & 0x0F) | 0b00110000;	//make it in 8-bit mode first, for 3 times
	lcd_e_clock();
   	__delay_ms(2);
   	LCD_DATA = (LCD_DATA & 0x0F) | 0b00110000;	//make it in 8-bit mode first, for 3 times
	lcd_e_clock();
   	__delay_ms(2);
   	LCD_DATA = (LCD_DATA & 0x0F) | 0b00110000;	//make it in 8-bit mode first, for 3 times
	lcd_e_clock();
   	__delay_ms(2);
   	
   	LCD_DATA = (LCD_DATA & 0x0F) | 0b00100000;	//make it in 4-bit mode
	lcd_e_clock();
   	__delay_ms(2);			
   	   	
	//start sending command in 4 bit mode
   	//Function Set
   	lcd_config(0b00101000);	 //0b 0 0 1 ID N F X X 							
   							//Interface Data Length, ID= 4-bit
   							//Number of line to display, N = 1 is 2 line display, N = 0 is 1 line display
   							//Display Font, F = 0 is 5x 8 dots, F = 1 is 5 x 11 dots
	
	//Command Entry Mode
	lcd_config(0b00000110);	//0b 0 0 0 0 0 1 ID SH
							//ID  = 1, cursor automatic move to right, increase by 1
   							//SH = 0,  shift of entire display is not perform   								
		
	//Display Control
	lcd_config(0b00001111);	//0b 0 0 0 0 1 D C B
							//D  = 1, Display is ON
   							//C = 0,  Cursor is not display
   							//B = 0. Cursor does not blink  					
	
	lcd_clear();	//clear LCD and move the cursor back to home position
}
Example #5
0
int main(void)
{
	uint8_t			data = 0x55;
	uint32_t		prevms = 0;
	PCF8574_STATUS	st;

	sei();
	i2c_begin();

	TCCR2A = 0;						//t2: stop
	TCCR2B = 0;
	GTCCR = _BV(PSRASY);			//t2: prescaler reset
	TCNT2 = 0;						//t2: reset counter

	TCCR2A = _BV(WGM21);			//t2: CTC mode
	OCR2A = 124;					//t2: 62.5*128*125 = 1000000 ns = 1 ms
	TIMSK2 = _BV(OCIE2A);			//t2 enable Timer2 Interrupt

	TCCR2B = _BV(CS20) | _BV(CS22);	//t2: prescaler 128 (start)

//	pcf8574_init(&st, 0x20, 0xff);

	_delay_ms(500);  //Initiaize LCD
	lcd_init();
	_delay_ms(200);
	lcd_clear();
	lcd_setcursor(1, 0);
	display("Hi");
	display(" There....");
	lcd_setcursor(0, 1);
	display("Circuits4You.com");


	while(1)
	{
//		pcf8574_write8(&st, data);
//		pcf8574_read8(&st, &data);
//		data ^= 0xff;
//		while(millis() - prevms < 1000 );
//		prevms += 1000;
	}
}
Example #6
0
void menu_adjust_contrast(void) {
  uint8_t i;
  uint8_t min = 0;
  uint8_t max = LCD_COLS - 2;
  uint8_t res;

  lcd_clear();
  lcd_puts_P(PSTR("Adjust LCD contrast"));
  lcd_locate(0, 1);

  lcd_cursor(false);
  set_busy_led(true);
  for (;;) {
    lcd_locate(0, 1);
    lcd_putc('[');
    for (i = 0; i < LCD_COLS - 2; i++) {
      lcd_putc(i >= lcd_contrast ? ' ' : 0xFF);
    }
    lcd_putc(']');
    res = lcd_set_contrast(lcd_contrast);
    if (res) break;
    for (;;) {
      if (get_key_autorepeat(KEY_PREV)) {
        if (lcd_contrast <= min) lcd_contrast = max;
        else --lcd_contrast;
        break;
      }
      if (get_key_autorepeat(KEY_NEXT)) {
        if (lcd_contrast >= max) lcd_contrast = min;
        else ++lcd_contrast;
        break;
      }
      if (get_key_press(KEY_SEL)) {
        lcd_cursor(false);
        set_busy_led(false);
        menu_ask_store_settings();
        return;
      }
    }
  }
  pwm_error();
}
Example #7
0
static int __devinit cobalt_lcdfb_probe(struct platform_device *dev)
{
	struct fb_info *info;
	struct resource *res;
	int retval;

	info = framebuffer_alloc(0, &dev->dev);
	if (!info)
		return -ENOMEM;

	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
	if (!res) {
		framebuffer_release(info);
		return -EBUSY;
	}

	info->screen_size = resource_size(res);
	info->screen_base = ioremap(res->start, info->screen_size);
	info->fbops = &cobalt_lcd_fbops;
	info->fix = cobalt_lcdfb_fix;
	info->fix.smem_start = res->start;
	info->fix.smem_len = info->screen_size;
	info->pseudo_palette = NULL;
	info->par = NULL;
	info->flags = FBINFO_DEFAULT;

	retval = register_framebuffer(info);
	if (retval < 0) {
		iounmap(info->screen_base);
		framebuffer_release(info);
		return retval;
	}

	platform_set_drvdata(dev, info);

	lcd_clear(info);

	printk(KERN_INFO "fb%d: Cobalt server LCD frame buffer device\n",
		info->node);

	return 0;
}
Example #8
0
void menu_key_test(void) {
    u8 i;
    u16 bit;
    
    // cleanup screen and disable possible low bat warning
    buzzer_off();
    key_beep();
    menu_battery_low = 0;	// it will be set automatically again
    battery_low_shutup = 0;

    // do full screen blink
    lcd_set_full_on();
    delay_menu_always(2);
    while (btns(BTN_ENTER))  stop();  // wait for release of ENTER
    lcd_clear();

    button_autorepeat(0);	// disable autorepeats
    btnra();

    // show intro text
    lcd_chars("KEY");
    lcd_update_stop();		// wait for key

    while (1) {
	if (btnl(BTN_BACK | BTN_ENTER))  break;

	for (i = 0, bit = 1; i < 16; i++, bit <<= 1) {
	    if (btn(bit)) {
		key_beep();
		lcd_chars(key_ids[i]);
		if (btnl(bit))  lcd_7seg(L7_L);
		else lcd_set(L7SEG, LB_EMPTY);
		lcd_update();
		break;
	    }
	}
	btnra();
	stop();
    }
    key_beep();
    apply_model_config();
}
Example #9
0
struct lcdInfo lcd_make(unsigned int rs,unsigned int e,unsigned int db[4]){
  struct lcdInfo lcdinfo;
  lcdinfo.rs = rs;
  lcdinfo.e = e;
  lcdinfo.db[0] = db[0];
  lcdinfo.db[1] = db[1];
  lcdinfo.db[2] = db[2];
  lcdinfo.db[3] = db[3];

  gpio_setOutput(lcdinfo.rs);
  gpio_setOutput(lcdinfo.e);
  gpio_setOutput(lcdinfo.db[0]);
  gpio_setOutput(lcdinfo.db[1]);
  gpio_setOutput(lcdinfo.db[2]);
  gpio_setOutput(lcdinfo.db[3]);

  lcd_clear(&lcdinfo);

  return lcdinfo;
}
Example #10
0
void lcd_putCharNow(const char charData) {
	unsigned char ddramAddress = lcd_getDdramAddress();	
	//if first string owerflows - write on second
	if ((ddramAddress > 0x0f) && (ddramAddress < 0x40)) {
		lcd_setDdramAddress(0x40);
	}
	if(_shouldBreakTheLine){
		_shouldBreakTheLine=0;
		lcd_clear();
	}
	if(charData=='\n'){
		_shouldBreakTheLine=1;
		return;
	}
	while(lcd_getBusyFlagState()) {}
	write_max(DATA_IND, charData);
	write_max(C_IND, 0x05);
	write_max(C_IND, 0x04);
	return;
}
/*******************************************************************************
* PUBLIC FUNCTION: lcd_initialize
*
* PARAMETERS:
* ~ void
*
* RETURN:
* ~ void
*
* DESCRIPTIONS:
* Initialize and clear the LCD display.
*
*******************************************************************************/
void lcd_initialize(void)
{
	// Set the LCD E pin and wait for the LCD to be ready before we
	// start sending data to it.
	set_lcd_e(1);
	__delay_ms(15);
	
	// Configure the Function Set of the LCD.	
	send_lcd_data(0, CMD_FUNCTION_SET | MSK_DL_8 | MSK_N | MSK_F);
	
	
	// Configure the entry mode set of the LCD.
	send_lcd_data(0, CMD_ENTRY_MODE_SET | MSK_ID | MSK_S);
	
	// Configure the display on/off control of the LCD.
	send_lcd_data(0, CMD_DISPLAY_CONTROL | MSK_D | MSK_C | MSK_B);
	
	// Clear the LCD display.
	lcd_clear();
}
//-------------------------------------------------------------------------------------
//LCD_Print function
//-------------------------------------------------------------------------------------
void LCD_Print(void) {
	if (new_print){ // Call display function every 400 ms 
		new_print =0;
		lcd_clear();
		lcd_print("\rHd: %u, dh: %u", heading/10, desired_heading/10);
		lcd_print("\rRange:%u", range);
		if(Counts==1){	//only call the battery voltage once every second
			battery=(read_AD_input(5));	//switch channels
			battery*=95;
			keypad = read_AD_input(4);	//Allow it stabilize. using this variable as just a throw away
			Counts=0;
		}//end if counts
		if(heading>desired_heading){
			lcd_print("\rVoltage:%d, left", (1*battery));	//hn//prints battery voltage to nearest volt
		} else if(heading<=desired_heading){
			lcd_print("\rVoltage:%d, right", (1*battery));	//prints battery voltage to nearest volt
		}
		lcd_print("\rOtp: %d, Htp: %d", near_obstical, trip_heading_change);
	}//end if new print
}//end LCD print
Example #13
0
/*****************************************************************************
 * Subroutine: lcd_init
 *
 * Description:
 * This subroutine initializes the LCD device.
 *
 * Input Parameters:
 * LCD struct reference
 *
 * Output Parameters:
 * None
 *
 * Subroutines:
 * lcd_clear
 * lcd_tx_byte
 * __delay_ms
 * __delay_us
 *****************************************************************************/
void lcd_init(LCD_t* lcd)
{
    write_pin(lcd->rw_pin, 0);
    write_pin(lcd->rs_pin, 0);
    
    /*** Power-On Initialization ***/
    /* Wait 15 ms */
    __delay_ms(15);
    
    /* Write 0x3, pulse enable, wait 4.1 ms or longer */
    *lcd->data_bus = 0x3 << lcd->bus_offset;
    strobe_pin(lcd->en_pin);
    __delay_ms(5);
    
    /* Write 0x3, pulse enable, wait 100 us or longer */
    *lcd->data_bus = 0x3 << lcd->bus_offset;
    strobe_pin(lcd->en_pin);
    __delay_us(100);
    
    /* Write 0x3, pulse enable, wait 40 us or longer */
    *lcd->data_bus = 0x3 << lcd->bus_offset;
    strobe_pin(lcd->en_pin);
    __delay_us(40);
    
    /* Write 0x2, pulse enable, wait 40 us or longer */
    *lcd->data_bus = 0x2 << lcd->bus_offset; /* Set 4-bit mode */
    strobe_pin(lcd->en_pin);
    __delay_us(40);
    
    /*** Display Configuration ***/
    lcd_tx_byte(lcd, 0x28); /* 4-bit operation */
    __delay_us(40);
    
    lcd_tx_byte(lcd, 0x06); /* Automatically increase address pointer */
    __delay_us(40);
    
    lcd_tx_byte(lcd, 0x0C); /* Turn display on */
    __delay_us(40);
    
    lcd_clear(lcd);
}
Example #14
0
int8_t Fan_State_On(uint8_t fan, int8_t input) {
	// Wert bearbeiten?
	if (input == MENU_INPUT_PUSH) {
		Fan_edit ^= 1;
		eeprom_write_byte((void*) &Fan_fansE[fan].timeM, Fan_fans[fan].timeM);
		eeprom_write_byte((void*) &Fan_fansE[fan].timeH, Fan_fans[fan].timeH);
	}
	if (Fan_edit && (input == MENU_INPUT_DOWN)) {
		if (Fan_fans[fan].timeM < 55) {
			Fan_fans[fan].timeM += 5;
		} else if (Fan_fans[fan].timeH < 23) {
			Fan_fans[fan].timeM = 0;
			Fan_fans[fan].timeH++;
		}
	}
	if (Fan_edit && (input == MENU_INPUT_UP)) {
		if (Fan_fans[fan].timeM > 0) {
			Fan_fans[fan].timeM -= 5;
		} else if (Fan_fans[fan].timeH > 0) {
			Fan_fans[fan].timeM = 55;
			Fan_fans[fan].timeH--;
		}
	}
	// Ausgabe
	lcd_clear();
	lcd_home();
	if (Fan_edit)
		lcd_data('*');
	else
		lcd_data('>');
	lcd_string_P(MENU_STR_ONTIME);
	lcd_number(Fan_fans[fan].timeH, 2, ' ');
	lcd_data(':');
	lcd_number(Fan_fans[fan].timeM, 2, '0');
	lcd_setcursor(0, 2);
	lcd_data(' ');
	lcd_string_P(MENU_STR_REPEAT);
	lcd_number(Fan_fans[fan].rep, 2, ' ');
	lcd_data('h');
	return Fan_edit;
}
Example #15
0
int8_t Fan_State_Ctrl(uint8_t fan, int8_t input) {
	// Wert bearbeiten?
	if (input == MENU_INPUT_PUSH) {
		Fan_edit ^= 1;
		eeprom_write_byte((void*) &Fan_fansE[fan].ctrl, Fan_fans[fan].ctrl);
	}
	if (Fan_edit && (input == MENU_INPUT_DOWN)) {
		Fan_fans[fan].ctrl = (Fan_fans[fan].ctrl < FAN_CTRL_MAX) ? (Fan_fans[fan].ctrl+1) : (FAN_CTRL_MAX);
	}
	if (Fan_edit && (input == MENU_INPUT_UP)) {
		Fan_fans[fan].ctrl = (Fan_fans[fan].ctrl > FAN_CTRL_MIN) ? (Fan_fans[fan].ctrl-1) : (FAN_CTRL_MIN);
	}
	// Ausgabe
	lcd_clear();
	lcd_home();
	if (Fan_edit)
		lcd_data('*');
	else
		lcd_data('>');
	lcd_string_P(MENU_STR_CTRL);
	switch (Fan_fans[fan].ctrl) {
		case FAN_CTRL_OFF:
			lcd_string_P(MENU_STR_CTRL_OFF);
			break;
		case FAN_CTRL_HUMI:
			lcd_string_P(MENU_STR_CTRL_HUMI);
			break;
		case FAN_CTRL_TIME:
			lcd_string_P(MENU_STR_CTRL_TIME);
			break;
		case FAN_CTRL_REP:
			lcd_string_P(MENU_STR_CTRL_REP);
			break;
	}
	lcd_setcursor(0, 2);
	lcd_data(' ');
	lcd_string_P(MENU_STR_HUMIDITY);
	lcd_number(Fan_fans[fan].humi, 2, ' ');
	lcd_data('%');
	return Fan_edit;
}
Example #16
0
/* ****************************************************************** */
void show_C_ESR() {
  uint8_t key_pressed;
  message_key_released(C_ESR_str);
#ifdef POWER_OFF
  uint8_t times;
  for (times=0;times<250;times++) 
#else
  while (1)		/* wait endless without the POWER_OFF option */
#endif
  {
        PartFound = PART_NONE;
        ReadBigCap(TP3,TP1);
        if (PartFound == PART_CAPACITOR) {
           lcd_line1();		// clear old capacity value 
           lcd_clear_line();
           lcd_line1();
           lcd_data('C');
           lcd_data('=');
           DisplayValue(cap.cval_max,cap.cpre_max,'F',3);
           cap.esr = GetESR(cap.cb,cap.ca);
           lcd_line2();		// clear old ESR value 
           lcd_clear_line();
           lcd_line2();
           lcd_MEM_string(&ESR_str[1]);
           if (cap.esr < 65530) {
              DisplayValue(cap.esr,-2,LCD_CHAR_OMEGA,2);
           } else {
              lcd_data('?');		// too big
           }
        } else {
           lcd_clear();
           lcd_MEM2_string(C_ESR_str);
        }
     key_pressed = wait_for_key_ms(1000);
#ifdef WITH_ROTARY_SWITCH
     if ((key_pressed != 0) || (rotary.incre > 3)) break;
#else
     if (key_pressed != 0) break;
#endif
  }  /* end for times */
} /* end show_C_ESR() */
Example #17
0
int main (void) {

  PINSEL10 = 0;                             /* Disable ETM interface */
  FIO2DIR = LEDMSK;                         /* LEDs, port 2, bit 0~7 output only */

  lcd_init();
  lcd_clear();
  lcd_print ("MCB2300 HID Demo");
  set_cursor (0, 1);
  lcd_print ("  www.keil.com  ");

  	Nr = 128;
	Nk = Nr / 32;
	Nr = Nk + 6;
	KeyExpansion(Key, Nk, Nr);

  USB_Init();                               /* USB Initialization */
  USB_Connect(TRUE);                        /* USB Connect */

  while (1);                                /* Loop forever */
}
Example #18
0
ICACHE_FLASH_ATTR
void user_init(void)
{
	os_delay_us(1000 * 1000);
	lcd_init();
	bignumbers_init();
	os_delay_us(1000 * 1000);
	lcd_clear();
	lcd_print("init");

	time_init();

	current_time.hour = 0xFF;
	current_time.minute = 0xFF;
	current_time.second = 0xFF;

    //Start os task
    system_os_task(outer_loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);

    system_os_post(user_procTaskPrio, 0, 0 );
}
Example #19
0
void printTime()
{	
		lcd_clear();
	
		c = RTC_HOUR/10 + '0';
		lcd_print(&c);	  
		c = RTC_HOUR%10 + '0';
		lcd_print(&c);
		lcd_print(":");
	
		c = RTC_MIN/10 + '0';
		lcd_print(&c);	  
		c = RTC_MIN%10 + '0';
		lcd_print(&c);
		lcd_print(":");
	
		c = RTC_SEC/10 + '0';
		lcd_print(&c);	  
		c = RTC_SEC%10 + '0';
		lcd_print(&c);
}
Example #20
0
///
/// Initializes the framebuffer and the network interfaces
///
void init()
{
    //cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_EMAC);

    // initialize profiling timebase
    if (profile_tbwdtInit() != 0) {
        diag_printf("TBWDT initialization failed.\n");
    }
#ifdef DO_STATETRACE
    reconos_clearStateTrace();
#endif

    lcd_init(24);
    lcd_clear();
    lcd_getinfo(&fb_info);
    diag_printf("framebuffer @ %dx%d\n", fb_info.width, fb_info.height);

    init_all_network_interfaces();
    diag_printf("eth0_up = %d\n", eth0_up);

}
Example #21
0
//LCD section is 0x1C
void instrCall_LCD(char instruction, char* datain, char dataLength)
{
  switch (instruction)
  {
  case LCD_INIT:
    {
      lcd_init();
      break;
    }
  case LCD_WRITE:
    {
      lcd_putString(datain, dataLength);
      break;
    }
  case LCD_CLEAR:
    {
      lcd_clear();
      break;
    }
  }
}
//we override __assert_func to flash the leds (so we know something bad has happend)
//and to repeat the error message repeatedly (so we have a chance to attach the device to a serial console before the error message is gone)
void __assert_func( const char *file, int line, const char *func, const char *failedexpr)
{
#if defined FRAMEWORK_DEBUG_ASSERT_REBOOT // make sure this parameter is used also when including assert.h instead of debug.h
        hw_reset();
#endif

	start_atomic();
	led_on(0);
	led_on(1);
#ifdef PLATFORM_USE_USB_CDC
	// Dissable all IRQs except the one for USB
	for(uint32_t j=0;j < EMU_IRQn; j++)
		NVIC_DisableIRQ(j);

	NVIC_EnableIRQ( USB_IRQn );

	end_atomic();
#endif

	lcd_clear();
	lcd_write_string("ERROR");
	lcd_write_number(timer_get_counter_value());

    __asm__("BKPT"); // break into debugger

	while(1)
	{
		printf("assertion \"%s\" failed: file \"%s\", line %d%s%s\n",failedexpr, file, line, func ? ", function: " : "", func ? func : "");

		for(uint32_t j = 0; j < 20; j++)
		{
			//blink at twice the frequency of the _exit call, so we can identify which of the two events has occurred
			for(uint32_t i = 0; i < 0xFFFFF; i++){}
			led_toggle(0);
			led_toggle(1);
		}
	}
	end_atomic();

}
Example #23
0
int main(void) {

    ANSEL=0;
    ANSELH=0;
    CM1CON0=0;
    CM2CON0=0;
    TRISA=0;
    TRISC=0;

    lcd_init();

    while (1==1)
    {
        lcd_clear();
        pause(100);
        lcd_goto(0);
        pause(1);
        for (b0=0; b0<10; b0=b0+1)
        {
            lcd_putch( b0 + number );
            pause(2);
        }
        lcd_goto(0x40);
        pause(2);

        _delay(4);

        __delay_us(1000);




        lcd_puts("Hello World");
        pause(20);
        lcd_puts("_EOF");
        pause(10);
    }

    return 0;
}
Example #24
0
void flashBootloader(const char * filename)
{
  FIL file;
  f_open(&file, filename, FA_READ);
  uint8_t buffer[1024];
  UINT count;

  lcd_clear();
  displayProgressBar(STR_WRITING);

  static uint8_t unlocked = 0;
  if (!unlocked) {
    unlocked = 1;
    unlockFlash();
  }

  for (int i=0; i<BOOTLOADER_SIZE; i+=1024) {
    watchdogSetTimeout(100/*1s*/);
    if (f_read(&file, buffer, 1024, &count) != FR_OK || count != 1024) {
      POPUP_WARNING(STR_SDCARD_ERROR);
      break;
    }
    if (i==0 && !isBootloaderStart((uint32_t *)buffer)) {
      POPUP_WARNING(STR_INCOMPATIBLE);
      break;
    }
    for (int j=0; j<1024; j+=FLASH_PAGESIZE) {
      writeFlash(CONVERT_UINT_PTR(FIRMWARE_ADDRESS+i+j), (uint32_t *)(buffer+j));
    }
    updateProgressBar(i, BOOTLOADER_SIZE);
    SIMU_SLEEP(30/*ms*/);
  }

  if (unlocked) {
    lockFlash();
    unlocked = 0;
  }

  f_close(&file);
}
Example #25
0
int main (void) {
  int i;
  

  Init_Timer1( );
  init_serial();                               /* Init UART                   */
  uart_init_0 ( );
  lcd_init();
  lcd_clear();
  lcd_print ("HSM AO Compare");
  set_cursor (0, 1);
  lcd_print ("EventDrivenSystem");

  for (i = 0; i < 10000; i++);       /* Wait for initial display           */
 

  comp_main();

 
 

}
Example #26
0
void show(char data[6][4]){
	lcd_clear();
	
	lcd_setcursor( 1, 1 );
	lcd_string(data[4]);
	
	lcd_setcursor( 6, 1 );
	lcd_string(data[3]);
	
	lcd_setcursor( 11, 1 );
 	lcd_string(data[2]);

	lcd_setcursor( 1, 2 );
	lcd_string(data[1]);
	
	lcd_setcursor( 6, 2 );
	lcd_string(data[0]);
	
	//PWM Signal:
	lcd_setcursor( 11, 2 );
	lcd_string(data[5]);
}
Example #27
0
void checkSwitches() //initial check
{
  if(! WARN_SW) return;
  uint8_t last=0;
  while(1){
    uint8_t i;
    for(i=SW_BASE_DIAG; i< SW_Trainer; i++)
    {
      if(i==SW_ID0) continue;
      if(keyState((EnumKeys)i)) break;
    }
    if(i==SW_Trainer) return;  
    if(last!=i) beepErr();
    last=i;
    lcd_clear();
    putsDrSwitches(0*FW,3*FH,i-SW_BASE_DIAG+1,0);
    lcd_puts_P(4*FW,3*FH,PSTR(" - Switch is on"));  
    if(! alert(PSTR(""),1+2+4) ) break;
  }
  //beepErr();
  //_pushMenu(menuProcDiagKeys);
}
Example #28
0
/**
 * BrewStrengthMenu state handler
 **/
static QState MenuAO_BrewStrengthMenu(MenuAO *me, QEvent const *e)
{
    switch ( e->sig )
    {
    case Q_INIT_SIG:
    {
        return Q_HANDLED();
    }

    case Q_ENTRY_SIG:
    {
        // display brew strength menu (1st row of LCD)
        sprintf(output, "2: Strength %d", 2*me->brewStrength+2);
        lcd_clear();
        set_cursor(0, 0);
        lcd_print((unsigned char*)output);

        return Q_HANDLED();
    }

    case BUTTON_SHORTPRESS_SIG:
    {
        // short press > proceed to next submenu
        return Q_TRAN(&MenuAO_AlarmMenu);
    }

    case BUTTON_LONGPRESS_SIG:
    {
        return Q_TRAN(&MenuAO_ChangeBrewStrength);
    }

    case Q_EXIT_SIG:
    {
        return Q_HANDLED();
    }
    }

    return Q_SUPER(&MenuAO_Idle);
}
Example #29
0
void lcd_init(void) {

    PTH = 0x00;                 // clear register
    DDRH = 0xFF;                // data bus as all outputs for writing
    PORTK &= REST_STATE;        // preset RS LOW, R/W LOW, EN LOW (11111000)
    DDRK |= 0x07;               // activate three control lines (00000111)

    // we require a delay period of longer than 15 ms: the following is about 49ms
    asm PSHD;
    asm LDD #0;
    asm DBNE D, *;      // 24.576 ms delay
    asm DBNE D, *;      // ... twice
    asm PULD;

    // default setup: 8-bit, 2 lines, 5x8 character matrix
    PTH = 0x38;
    PORTK |= CONTROL_WRITE;
    PORTK &= REST_STATE;

    // we require a delay period of more than 4.1ms: the following is about 4.125ms
    asm PSHD;
    asm LDD #11000;
    asm DBNE D, *;
    asm PULD;

    PORTK |= CONTROL_WRITE;
    PORTK &= REST_STATE;

    // we require a delay period of more than 100us: the following is about 100us
    asm PSHD;
    asm LDD #267;
    asm DBNE D, *;
    asm PULD;

    lcd_tx_control(0x38);       // default setup: 8-bit, 2 lines, 5x8 character matrix
    lcd_tx_control(0x0E);       // control for cursor settings: display on, cursor on, blink off
    lcd_tx_control(0x06);       // control for cursor settings: increments to the left, no shift
    lcd_clear();
}
Example #30
0
void to_lcd()
{
  unsigned char s[8]={0}; 
  
  lcd_clear();
        
  lcd_gotoxy(0,0);sprintf(s,"A%u",SH_LEFT);lcd_puts(s);
  lcd_gotoxy(4,0);sprintf(s,"A%u",SH_CENTER);lcd_puts(s);                
      
  lcd_gotoxy(0,1);lcd_puts("SP");itoa(ROBOT_SPEED,s);lcd_puts(s);                                                     
      
  //if(IR_SENSOR) {lcd_gotoxy(0,1);lcd_puts("IR_S");};
  //if(RIGHT_BREAKER) {lcd_gotoxy(0,1);lcd_puts("BR_R");};  
  //if(LEFT_BREAKER) {lcd_gotoxy(0,1);lcd_puts("BR_L");};
        
  lcd_gotoxy(5,1);
  switch(CURR_S)
        {
          case S0:{lcd_puts("S0");break;};       
          case S1:{lcd_puts("S1");break;};
          case S2:{lcd_puts("S2");break;};
          case S3:{lcd_puts("S3");break;};
          case S40:{lcd_puts("S40");break;};
          case S41:{lcd_puts("S41");break;};
          default:{lcd_puts("NO");break;};
        };
         
  //float voltage,temp; //calculate voltage;    
  /////////////////////////V
  /*voltage=u2*0.0049;temp = voltage*1000;
  
  lcd_gotoxy(0,1);lcd_putchar('U');lcd_putchar('=');   
  i=temp/1000;temp-=i*1000;lcd_putchar(0x30+i);
  lcd_putchar(',');
  i=temp/100;temp-=i*100;lcd_putchar(0x30+i);
  i=temp/10;temp-=i*10;lcd_putchar(0x30+i);  
  i=temp;lcd_putchar(0x30+i);
  lcd_putchar('v'); */               
};