Exemplo n.º 1
0
void matemat_process(void)
{
    static uint8_t state = 0;
    static uint8_t timer = 0;

    if(kick){
        cli();
        matemat_global.temps[TEMP_BOTTOM] = GET_BOTTOM;
        printtemp(matemat_global.temps[TEMP_BOTTOM],3,8);
        matemat_global.temps[TEMP_MIDDLE] = GET_MIDDLE;
        printtemp(matemat_global.temps[TEMP_MIDDLE],2,8);
        
        hd44780_goto(1,0);
        fprintf(lcd,"%d",matemat_global.matemat_packetcount);
        hd44780_goto(3,19);
        if(state)
            hd44780_put('.',NULL);
        else
            hd44780_put(' ',NULL);
        sei();
        
        //hd44780_goto(1,19);
        //hd44780_put(pl,NULL);

        //if( (PINC & (1<<PC4)) )
        //    hd44780_put('2',NULL);
        //else if( (PINC & (1<<PC3)) )
        //    hd44780_put('3',NULL);
        //else
        //    hd44780_put('-',NULL);
        state = !state;

        if(matemat_global.mode == MODE_IDLE){
            if(matemat_global.temps[TEMP_BOTTOM] > matemat_global.temps[TEMP_START]){
                matemat_global.mode = MODE_COOLING;
                matemat_putmode();
                PIN_SET(MATEMAT_COOLER);
            }
        }else if(matemat_global.mode == MODE_COOLING){
            if(matemat_global.temps[TEMP_BOTTOM] < matemat_global.temps[TEMP_STOP]){
                matemat_global.mode = MODE_IDLE;
                matemat_putmode();
                PIN_CLEAR(MATEMAT_COOLER);
            }
        }

        kick = 0;
        if(timer++ == 10){
            matemat_global.push = 1;
            timer = 0;
        }
    }
   
}
Exemplo n.º 2
0
void matemat_setupdisp(void)
{
    hd44780_clear();
    hd44780_goto(0,0);
    fprintf_P(lcd, PSTR("   Matemat ready"));
    
    hd44780_goto(2,0);
    fprintf_P(lcd, PSTR("Middle: \n"));

    hd44780_goto(3,0);
    fprintf_P(lcd, PSTR("Bottom: \n"));

    hd44780_goto(1,17);
    fprintf_P(lcd, PSTR("PL"));
}
Exemplo n.º 3
0
void ui_temp_param_display(void) {
	uint8_t j;
	display_unit_label(PSTR("T"));
	hd44780_label(PSTR("F"),TRUE,FALSE);
	hd44780_out8hex(temp_sensors[menu_unit()].flags);
	hd44780_out8hex(temp_sensors[menu_unit()].bad_reads);
	hd44780_label(PSTR("A"),TRUE,FALSE);
	hd44780_switch_state(temp_sensors[menu_unit()].flags & _BV(TEMP_ALARM_MIN),FALSE);
	hd44780_switch_state(temp_sensors[menu_unit()].flags & _BV(TEMP_ALARM_MAX),FALSE);
	hd44780_switch_state(!(temp_sensors[menu_unit()].flags & _BV(TEMP_SENSOR_STATUS_OK)),FALSE);
	hd44780_next_line();
	for (j=0;j<8;j++) {
		hd44780_out8hex(temp_sensors[menu_unit()].rom[j]);
	}

	switch (menu_phase()) {
	case 0:
					menu_standard_top();
					break;
	case 1:
					menu_set_phase();
					break;
	case 2:
					hd44780_goto(1,3);
					menu_standard_unit(TEMP_SENSORS_NUM);
					break;
	case 3:
					menu_reset_phase();
					break;
	}

}
Exemplo n.º 4
0
void ui_temp_outputs_cooling_display(void) {

	if (!MENU_F(MENU_VARS_LOADED_FLAG)) {
		load_output_name(EEPROM_OUTS_SETTING_BEGIN,temp_sensors[menu_unit()].out_cooling);
		MENU_SF(MENU_VARS_LOADED_FLAG);
	}

	display_unit_label(PSTR("T"));
	hd44780_outstrn_P(SPACE_S);
	hd44780_outstrn_P(PSTR("Chlodzace"));
	display_break_line(3,2);
	display_out_long(temp_sensors[menu_unit()].out_cooling);
	hd44780_outstrn_P(PAR_S);

	switch (menu_phase()) {
	case 0:
					menu_standard_top();
					break;
	case 1:
					menu_set_phase();
					break;
	case 2:
					hd44780_goto(1,3);
					menu_standard_unit(TEMP_SENSORS_NUM);
					break;
	case 3:
					menu_mod_uint8(2,13,&temp_sensors[menu_unit()].out_cooling,0,OUTPUTS_NUM,TRUE);
					break;
	case 4:
					save_temp_sensor_settings(EEPROM_TEMP_SETTINGS_BEGIN,menu_unit());
					menu_reset_phase();
					break;
	}
}
Exemplo n.º 5
0
void matemat_putmsg(void)
{
    cli();
    hd44780_goto(0,0);
    fprintf(lcd,msg);
    sei(); 
}
Exemplo n.º 6
0
void main(void) {

	// lcd display
	struct dev_hd44780_ctx lcd_ctx;
	memset((void *)&lcd_ctx, 0x00, sizeof(struct dev_hd44780_ctx));

	lcd_ctx.rs.port = &LCD_RS_PORT;
	lcd_ctx.rs.pin = LCD_RS_PIN;
	lcd_ctx.e.port = &LCD_E_PORT;
	lcd_ctx.e.pin = LCD_E_PIN;

	// setup data lines
	for (uint8_t x = 0; x<4; x++) {
		lcd_ctx.data[x].port = &LCD_DB_PORT;
		lcd_ctx.data[x].pin = LCD_DB_PIN_FIRST + x;
	}

	// display specifics
	lcd_ctx.lines = LCD_NUMBER_OF_LINES;
	lcd_ctx.font = HD44780_FONT_5X8;

	// initialize the device
	hd44780_init(&lcd_ctx);

	// clear the display initially 
	hd44780_clrscr(&lcd_ctx);

	hd44780_goto(&lcd_ctx, 0x00);
	hd44780_puts(&lcd_ctx, "Hello World");

	// execution loop
	for (;;);
}
Exemplo n.º 7
0
void ui_outputs_status_display(void) {
	if (SF(FLAG_FORCE_LCD_REFRESH)) {
		if (alarms_is_active() && alarms_notification_enabled()) {
			hd44780_outstrn_P(PSTR("   ! ALARM !    "));
		} else {
			lcd_clock();
		}
		hd44780_goto(2,1);
		lcd_outputs_status();
	} else {
		if (alarms_is_active() && alarms_notification_enabled()) {
			hd44780_outstrn_P(PSTR("     ALARM      "));
		} else {
			hd44780_goto(1,3);
			hd44780_outstrn_P(SPACE_S);
		}
	}
}
Exemplo n.º 8
0
void ui_temp_status_display(void) {
	if (SF(FLAG_FORCE_LCD_REFRESH)) {
		lcd_temp_sensor(0);
		lcd_temp_sensor(1);
		hd44780_goto(2,1);
		lcd_temp_sensor(2);
		lcd_temp_sensor(3);
	} else {
		lcd_clear_temp_indicators();
	}
}
Exemplo n.º 9
0
ISR(TIMER0_OVF_vect , ISR_BLOCK)
{
    static unsigned int i=0;
    static unsigned char count1=0;
    static unsigned char count3=0;
    if(i-- == 0){
        i = 3588;
        kick = 1;
    }

    if(grant)
        grant--;

    if(PINC & (1<<PC4)){
        if(pl == '-' && count1++ == 70){
            pl = '1';
            hd44780_goto(1,19);
            hd44780_put(pl,NULL);
        }
    }else{
        count1=0;
    }

    if(PINC & (1<<PC3)){
        if(pl == '-' && count3++==70){
            pl = '3';
            hd44780_goto(1,19);
            hd44780_put(pl,NULL);
        }
    }else{
        count3=0;
    }

    if(!grant && count3==0 && count1==0 && pl != '-'){
        PORTC &= ~(1<<PC5);
        PORTC &= ~(1<<PC6);
        pl = '-';
        hd44780_goto(1,19);
        hd44780_put(pl,NULL);
    }
}
Exemplo n.º 10
0
//========================================================= temp ==========================================================
void ui_temp_settings_display(void) {
	display_unit_label(PSTR("T"));
	hd44780_switch_state(!(temp_sensors[menu_unit()].flags & _BV(TEMP_SENSOR_ROLE_0)),FALSE);
	hd44780_outstrn_P(SPACE_S);
	display_temp_value(temp_sensors[menu_unit()].target);
	hd44780_outstrn_P(SPACE_S);
	display_temp_value(temp_sensors[menu_unit()].target_night);
	display_break_line(2,0);
	display_temp_value(temp_sensors[menu_unit()].min);
	hd44780_outstrn_P(SPACE_S);
	display_temp_value(temp_sensors[menu_unit()].max);
	display_temp_value(temp_sensors[menu_unit()].histeresis);
	hd44780_outstrn_P(PAR_S);

	switch (menu_phase()) {
	case 0:
					menu_standard_top();
					break;
	case 1:
					menu_set_phase();
					break;
	case 2:
					hd44780_goto(1,3);
					menu_standard_unit(TEMP_SENSORS_NUM);
					break;
	case 3:
					menu_mod_bit(1,4,&(temp_sensors[menu_unit()].flags),TEMP_SENSOR_ROLE_0);
					break;
	case 4:
					menu_mod_temp(1,9,&(temp_sensors[menu_unit()].target));
					break;
	case 5:
					menu_mod_temp(1,15,&(temp_sensors[menu_unit()].target_night));
					break;
	case 6:
					menu_mod_temp(2,4,&(temp_sensors[menu_unit()].min));
					break;
	case 7:
					menu_mod_temp(2,10,&(temp_sensors[menu_unit()].max));
					break;
	case 8:
					tmp_var = pgm_read_byte(&TEMP_CONVERT_DS_TO_DEC[temp_sensors[menu_unit()].histeresis]);
					menu_mod_uint8(2,15,&tmp_var,1,9,TRUE);
					temp_sensors[menu_unit()].histeresis = pgm_read_byte(&TEMP_CONVERT_DEC_TO_DS[tmp_var]);
					break;
	case 9:
					save_temp_sensor_settings(EEPROM_TEMP_SETTINGS_BEGIN,menu_unit());
					menu_reset_phase();
					break;
	}
}
Exemplo n.º 11
0
int16_t parse_cmd_lcd_clear(char *cmd, char *output, uint16_t len)
{
    if(*cmd)
	{
		uint8_t line = atoi(cmd);

        if (line > (LCD_LINES - 1) )
            return ECMD_ERR_PARSE_ERROR;

        hd44780_goto(line, 0);
        for (uint8_t i = 0; i < LCD_CHAR_PER_LINE; i++)
            fputc(' ', &lcd);
        hd44780_goto(line, 0);

        return ECMD_FINAL_OK;
    }
	else
	{
        hd44780_clear();
        hd44780_goto(0, 0);
        return ECMD_FINAL_OK;
    }
}
Exemplo n.º 12
0
void lcd_clear_temp_indicators(void) {
	hd44780_goto(1,2);
	hd44780_outstrn_P(SPACE_S);
	hd44780_goto(1,8);
	hd44780_outstrn_P(SPACE_S);
	hd44780_goto(1,10);
	hd44780_outstrn_P(SPACE_S);
	hd44780_goto(1,16);
	hd44780_outstrn_P(SPACE_S);
	hd44780_goto(2,2);
	hd44780_outstrn_P(SPACE_S);
	hd44780_goto(2,8);
	hd44780_outstrn_P(SPACE_S);
	hd44780_goto(1,1);
}
Exemplo n.º 13
0
void matemat_putmode(void)
{
    cli();
    hd44780_goto(1,10);
    switch(matemat_global.mode){
        case MODE_IDLE:
            fprintf_P(lcd, PSTR("idle   "));
        break;
        case MODE_COOLING:
            fprintf_P(lcd, PSTR("cooling"));
        break;
        default:
            fprintf_P(lcd, PSTR("?mode? "));
        break;
    }
    sei();
}
Exemplo n.º 14
0
/*
  If enabled in menuconfig, this function is periodically called
  change "timer(100,app_sample_periodic)" if needed
*/
int16_t
app_sample_periodic(void)
{
  APPSAMPLEDEBUG ("periodic\n");
  // enter your code here

  clock_datetime_t date;
  clock_current_localtime(&date);

  hd44780_goto(3, 0);

  char tmp_buf [20];
  sprintf (tmp_buf,"%02d.%02d.%04d  %02d:%02d:%02d", date.day, date.month, date.year + 1900, date.hour, date.min, date.sec);
  fputs (tmp_buf, &lcd);



  return ECMD_FINAL_OK;
}
Exemplo n.º 15
0
/** Czyści cały log
*/
void log_clear(void) {
	uint16_t i;
	uint8_t j = 0;
	for (i=LOG_FIRST_RECORD_NUMBER;i<=LOG_LAST_RECORD_NUMBER;i++) {
		hd44780_home();
		hd44780_outstrn_P(PSTR(" Czyszcz. loga  "));
		hd44780_goto(2,1);
		hd44780_outstrn_P(PSTR(" Rek.  "));
		hd44780_out16dec(i);
		hd44780_outstrn_P(PSTR("/"));
		hd44780_out16dec(LOG_LAST_RECORD_NUMBER);
		if (++j > LOG_RECORD_CLEAR_MAX) {
			j=0;
			wdt_reset();
		}
		log_clear_record(i);
	}
	log_write_pointer(LOG_CONTROL_RECORD_NUMBER);
}
Exemplo n.º 16
0
void ui_temp_sensor_discover(void) {
	hd44780_outstrn_P(DISCOVER_SENSOR_MENU_S);

	switch (menu_phase()) {
	case 0:
					menu_standard_top();
					break;
	case 1:
					menu_set_phase();
					break;
	case 2:
					hd44780_goto(2,16);
					menu_standard_phase();
					break;
	case 3:
					temp_discover_sensors();
					menu_reset_phase();
					break;
	}

}
Exemplo n.º 17
0
void ui_alarms_clear(void) {

	hd44780_outstrn_P(ALARMS_CLEAR_MENU_S);

	switch (menu_phase()) {
	case 0:
					menu_standard_top();
					break;
	case 1:
					menu_set_phase();
					break;
	case 2:
					hd44780_goto(2,16);
					menu_standard_phase();
					break;
	case 3:
					alarms_clear();
					menu_reset_phase();
					break;
	}
}
Exemplo n.º 18
0
int16_t parse_cmd_lcd_goto(char *cmd, char *output, uint16_t len)
{
#ifdef TEENSY_SUPPORT
	uint8_t line, pos = 0;

	/* Skip leading spaces. */
	while(*cmd == 32) cmd ++;

	/* Seek space (pos argument), chop and atoi to `pos'.  */
	char *p = cmd;
	while(*p && *p != 32) p ++;
	if(*p)
	{
		*p = 0;
		pos = atoi(p + 1);
	}

	line = atoi(cmd);
#else
	uint16_t line, pos = 0;

    int ret = sscanf_P(cmd,
            PSTR("%u %u"),
            &line, &pos);
	if(!ret) return ECMD_ERR_PARSE_ERROR;
#endif

    if (line > 3)
		return ECMD_ERR_PARSE_ERROR;

	if (LO8(pos) >= 20)
		pos = 20;

	debug_printf("going to line %u, pos %u\n", line, pos);

	hd44780_goto(LO8(line), LO8(pos));
	return ECMD_FINAL_OK;
}
Exemplo n.º 19
0
int16_t parse_cmd_lcd_goto(char *cmd, char *output, uint16_t len)
{
#ifdef TEENSY_SUPPORT
	uint8_t line, pos = 0;

	/* Skip leading spaces. */
	while(*cmd == ' ') cmd ++;

	/* Seek space (pos argument), chop and atoi to `pos'.  */
	char *p = cmd;
	while(*p && *p != ' ') p ++;
	if(*p)
	{
		*p = 0;
		pos = atoi(p + 1);
	}

	line = atoi(cmd);
#else
	uint16_t line, pos = 0;

    int ret = sscanf_P(cmd,
            PSTR("%u %u"),
            &line, &pos);
	if(!ret) return ECMD_ERR_PARSE_ERROR;
#endif

    if (line > (LCD_LINES - 1))
		return ECMD_ERR_PARSE_ERROR;

	if (LO8(pos) > LCD_CHAR_PER_LINE)
		pos = LCD_CHAR_PER_LINE;

	hd44780_goto(LO8(line), LO8(pos));
	return ECMD_FINAL_OK;
}
Exemplo n.º 20
0
void printtemp(uint16_t t, uint8_t x, uint8_t y){
    char buf[20];
    hd44780_goto(x,y);
    sprintf_temp(buf, t, 1);
    fprintf(lcd,buf);
}
Exemplo n.º 21
0
//TODO: don't work (no center)
void hd44780_message_center(const char *s, uint8_t line) {
	hd44780_goto(line, (HD44780_DISP_LENGTH - strlen(s)) / 2 + 1);
	hd44780_write_string(s);
}
Exemplo n.º 22
0
void hd44780_rewrite_string(const char *s) {
	hd44780_goto(1,1);
	hd44780_write_string(s);
}