Exemple #1
0
/*************************************************************************
Initialize display and select type of cursor 
Input:    dispAttr LCD_DISP_OFF            display off
                   LCD_DISP_ON             display on, cursor off
                   LCD_DISP_ON_CURSOR      display on, cursor on
                   LCD_DISP_CURSOR_BLINK   display on, cursor on flashing
Returns:  none
*************************************************************************/
void lcd_init(uint8_t dispAttr)
{
    #if LCD_PCF8574_INIT == 1
    //init pcf8574
    pcf8574_init();
    #endif

    #if LCD_LED == 1
    lcd_led(1);
    #endif

    dataport = 0;

    pcf8574_setoutput(LCD_PCF8574_DEVICEID, dataport);

    delay(16000);        /* wait 16ms or more after power-on       */

    /* initial write to lcd is 8bit */
//    dataport |= _BV(LCD_DATA1_PIN);  // _BV(LCD_FUNCTION)>>4;
//    dataport |= _BV(LCD_DATA0_PIN);  // _BV(LCD_FUNCTION_8BIT)>>4;
    
//    lcd_e_toggle();
//    delay(4992);         /* delay, busy flag can't be checked here */
   
    /* repeat last command */ 
//    lcd_e_toggle();      
    //delay(64);           /* delay, busy flag can't be checked here */
//    delay(4992);           /* delay, busy flag can't be checked here */
    
    /* repeat last command a third time */
//    lcd_e_toggle();      
    //delay(64);           /* delay, busy flag can't be checked here */
//    delay(4992);           /* delay, busy flag can't be checked here */

    /* now configure for 4bit mode */
    //dataport &= ~_BV(LCD_DATA0_PIN);
    dataport |= _BV(LCD_DATA1_PIN);
    lcd_e_toggle();
    delay(128);           /* some displays need this additional delay */

    lcd_e_toggle();
    delay(128);

    dataport &= ~_BV(LCD_DATA1_PIN);
    dataport |= _BV(LCD_DATA3_PIN);
    lcd_e_toggle();
    delay(128);
    
    /* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */    

    lcd_command(LCD_FUNCTION_DEFAULT);      /* function set: display lines  */

//    lcd_command(LCD_DISP_OFF);              /* display off                  */
    lcd_clrscr();                           /* display clear                */
    lcd_command(LCD_MODE_DEFAULT);          /* set entry mode               */
    lcd_command(dispAttr);                  /* display/cursor control       */

}/* lcd_init */
MainWorker::MainWorker() :
		_sensorsIface(DALL_PORT), _sensors(_sensorsIface), _network(_sensors,
				HWdata, _mainbuf)
{
	init();

	HWdata.pinsSetup();
	startClock();
	_iface = &_sensorsIface;

	lcd_init(LCD_DISP_ON);
	lcd_led(0);

	debugSDcardLog.begin();
	debug(F("-------Hello-------\r\n"));

	_sensorsIface.DS2480B_Detect();
	debugSDcardLog.end();

	/*** todo for debug ***/
//	_mainbuf[0] = "28:2F:15:F5:04:00:00:4C";
//	_mainbuf[1] = "28:41:14:70:03:00:00:73";
	/**********************/

	loadMainbuff();



#ifdef LEVEL_INFO
	uint16_t i = 0;
	INFO(F("Sensor ROMs in memory:"));
	for (; ((!_mainbuf[i].isNull()) && (i < ROM_MAINBFF_SIZE)); i++)
	{
		debug(_mainbuf[i].toString());
		debug("\r\n");
	}
	char buff[10];
	sprintf(buff, "count: %d", i);
	debug(buff);
	debug("\r\n");
#endif
}