예제 #1
0
void menu_display_status(void)
{
    static uint8_t cnt_main_monitor;

    //lcd_clear_line( 1 );

    //lcd_clear_line( 2 );
    lcd_gotoxy( 17, 2 ); lcd_puts("   ");
    lcd_gotoxy( 0, 2 );
    lcd_puts("MQTT/UDP:");
    lcd_puti( mqtt_io_count % 100 ); // Take 2 digits

/*
    lcd_puts(" ModBus:");
    lcd_puti( modbus_event_cnt % 100 ); // Take 2 digits
    lcd_putc( (cnt_main_monitor++ & 1) ? ':' : '.' );
    lcd_puti( (modbus_crc_cnt+modbus_exceptions_cnt) % 100 ); // Take 2 digits
    //lcd_puts("  ");
*/
    //lcd_clear_line( 3 );
    lcd_gotoxy( 16, 3 ); lcd_puts("    ");
    lcd_gotoxy( 0, 3 );
    lcd_puts("EEprom:");
    lcd_putc( ui_marker_unsaved ? '*' : '.' );
    lcd_puts(" 1WErr:");
    lcd_puti( ow_error_cnt % 100 ); // Take 2 digits
    //lcd_puts("  ");

    lcd_gotoxy( 0, 0 );
    lcd_puts("IO Status  ");
}
예제 #2
0
void main(void)
{
unsigned int range=0;
unsigned char counter1=0, gain=0;

/* Delay is there to ensure that SRF08 is out of reset and operational */
/* 
delay(1000000);
srf08_change_i2c_address(SRF08_UNIT_1); 
delay(100000);
*/

/*
   By default SRF_UNIT_0 is selected so the below command shows that the change of i2c address
   by the above "srf08_change_i2c_address(SRF08_UNIT_1);" command was succesfull.
   All commands after this, refer to that unit only! 
*/
srf08_select_unit(SRF08_UNIT_1);   

srf08_init();                      /* Only the selected SRF08 unit will be initialized!     */  
gain=SRF08_MAX_GAIN;
srf08_set_gain(gain);
srf08_set_range(SRF08_MAX_RANGE);   /* Set range to 11008 mm */ 

lcd_init();
lcd_clrscr();
lcd_gotoxy(0,0); lcd_puts_P("RANGE (E1)  = ");
lcd_gotoxy(0,1); lcd_puts_P("RANGE (E2)  = ");
lcd_gotoxy(0,2); lcd_puts_P("RANGE (E5)  = ");
lcd_gotoxy(0,3); lcd_puts_P("LIGHT sensor= ");

while(1)
    {
       
       /* AVERAGING FILTER */
       for(counter1=0,range=0; counter1<AVG_FLT_SAMPLES; counter1++)
         {
            range+=srf08_ping(SRF08_CENTIMETERS);
         } 
       range /= AVG_FLT_SAMPLES;

       /* AUTOMATIC GAIN CONTROL */
       if(srf08_read_register(SRF08_ECHO_5)!=0 )
        { 
           if(gain>=5) { srf08_set_gain(gain-=5); } else { srf08_set_gain(gain=0); }  
        } 
       else if(srf08_read_register(SRF08_ECHO_2)<=0 && gain!=31) { srf08_set_gain(++gain); } 

       /* DISPLAY TO LCD */
       lcd_gotoxy(14,0); lcd_puti(range,2);
       lcd_gotoxy(14,1); lcd_puti(srf08_read_register(SRF08_ECHO_2), 2);
       lcd_gotoxy(14,2); lcd_puti(srf08_read_register(SRF08_ECHO_5), 2);
       lcd_gotoxy(14,3); lcd_puti(srf08_read_register(SRF08_LIGHT),  2);


    }

return;
}
예제 #3
0
int main()
{

    cli();
    //unsigned char csr = MCUCSR;
    MCUCSR = 0;

#if USE_WDOG
    wdt_disable();
#endif

    init_devices();
    flash_led2_once();

    lcd_clear();
    lcd_gotoxy( 0, 0 );
    lcd_puts("Load EEPROM:");
    lcd_gotoxy( 0, 1 );

    load_eeprom_settings();
    flash_led1_once();

#if USE_WDOG
    wdt_enable(WDTO_2S);
#endif

    for (;;)
    {
        modbus_process_rx();
#if 1
        menu_run();
#else
        lcd_gotoxy( 0, 0 );

        int i;

        i = adc_value[6] >> 5;
        lcd_puts("vr1=");
        lcd_puti(i);
        i = adc_value[7] >> 5;
        lcd_puts(" vr2=");
        lcd_puti(i);
        lcd_puts("  ");
#endif

#if USE_WDOG
        wdt_reset();
#endif
    }


    while(1)
        ; // die here

    return 1;
}
예제 #4
0
void menu_monitor_bus(void)
{
    uint8_t bus = encoder % N_1W_BUS;
    if(bus >= N_1W_BUS) bus = N_1W_BUS-1;

    lcd_gotoxy( 0, 1 );

    lcd_puts("1W errors:  ");
    lcd_puti( ow_error_cnt ); //ow_bus_error_cnt[bus]);
    lcd_puts("  ");

    if( changed & KEY_OK )        select_menu( &menu_main );
}
예제 #5
0
static void menu_put_temp(uint8_t id)
{
    id %= SERVANT_NTEMP;

    lcd_puts("T");
    if( id < 10 ) lcd_putc(' ');
    lcd_puti(id);
    lcd_puts(": ");
    lcd_put_temp(currTemperature[id]);
    //lcd_puts(" B.");
    //lcd_puti(gTempSensorBus[id]);
    lcd_puts("  ");
}
예제 #6
0
void menu_display_bus(void)
{
    uint8_t bus = 0; //encoder % N_1W_BUS;    if(bus >= N_1W_BUS) bus = N_1W_BUS-1;

    uint8_t i, c = 0;
    for( i = 0; i < nTempSensors; i++ )
        if( gTempSensorBus[i] == bus )
            c++;

    lcd_gotoxy( 0, 0 );

    lcd_puts("1W sensors: ");
    lcd_puti(c);
    lcd_puts(" ");
}
예제 #7
0
void display_adc_readings(void)
{
unsigned long adc_reading=0;   
  
    
  adc_reading=adc_get_channel(0); 
  adc_reading=(adc_reading*10000)/adc_1Vx10;
  lcd_gotoxy(4,0); lcd_puti(adc_reading,3);
  
  
  adc_reading=adc_get_channel(4); 
  adc_reading=(adc_reading*10000)/adc_1Vx10;
  lcd_gotoxy(15,0); lcd_puti(adc_reading,3);
  
  
  adc_reading=adc_get_channel(1); 
  adc_reading=(adc_reading*10000)/adc_1Vx10;
  lcd_gotoxy(4,1); lcd_puti(adc_reading,3);

  
  adc_reading=adc_get_channel(5); 
  adc_reading=(adc_reading*10000)/adc_1Vx10;
  lcd_gotoxy(15,1); lcd_puti(adc_reading,3);
  
  
  adc_reading=adc_get_channel(2); 
  adc_reading=(adc_reading*10000)/adc_1Vx10;
  lcd_gotoxy(4,2); lcd_puti(adc_reading,3);
  
  
  adc_reading=adc_get_channel(6); 
  adc_reading=(adc_reading*10000)/adc_1Vx10;
  lcd_gotoxy(15,2); lcd_puti(adc_reading,3);
 
  
  adc_reading=adc_get_channel(3); 
  adc_reading=(adc_reading*10000)/adc_1Vx10;
  lcd_gotoxy(4,3); lcd_puti(adc_reading,3);
  
 
  adc_reading=adc_get_channel(7); 
  adc_reading=(adc_reading*10000)/adc_1Vx10;
  lcd_gotoxy(15,3); lcd_puti(adc_reading,3);

return;
}
예제 #8
0
void main(void)
{
unsigned int range=0;
unsigned char counter1=0, gain=0;

/*
    To change the SRF08 i2c address use the below given algorithm.
    Delay (1E6 microseconds=1 second) is there to ensure that SRF08 is out of reset and operational.
    Make sure that the SRF08 unit that you wish to change the address of,
    is selected before issuing the srf08_change_i2c_address(SRF08_UNIT_X) command.
    If you are not sure about the address then make sure that the only device connected to the I2C bus
    is a single SRF08 unit and use the "srf08_select_unit(SRF08_BROADCAST_ADDRESS)" command
    instead of the "srf08_select_unit(SRF08_UNIT_X)" command.
    The "srf08_select_unit(SRF08_BROADCAST_ADDRESS)" transmits to all SRF08 units. 
    After the address change the SRF08_UNIT_X is selected and active.
    Also remember to disable the algorithm afterwards (by commenting it or erasing it),
    recompile and flash the device again otherwise in every reset the address of the
    particular SRF08 unit will be changed (except if you want for this to happen!).

#define START_UP_DELAY  ( (1000000*(F_CPU/60000))/100 )
unsigned long delay=0;
delay=START_UP_DELAY;
while(delay) delay--; 
srf08_select_unit(SRF08_UNIT_0);
srf08_change_i2c_address(SRF08_UNIT_1); 
delay=START_UP_DELAY;
while(delay) delay--; 
*/


/*
   By default SRF_UNIT_0 is selected so the below command is not needed actually.
   All commands after the "srf08_select_unit(SRF08_UNIT_0);" command refer to that unit only! 
*/

srf08_select_unit(SRF08_UNIT_0);   
gain=SRF08_MAX_GAIN;
srf08_set_gain(gain);
srf08_set_range(SRF08_MAX_RANGE);   /* Set range to 11008 mm */ 

lcd_clrscr();
lcd_gotoxy(0,0); lcd_puts_P("RANGE (E1)  = ");
lcd_gotoxy(0,1); lcd_puts_P("RANGE (E2)  = ");
lcd_gotoxy(0,2); lcd_puts_P("RANGE (E5)  = ");
lcd_gotoxy(0,3); lcd_puts_P("LIGHT sensor= ");

while(1)
    {
       
       /* AVERAGING FILTER */
       for(counter1=0,range=0; counter1<AVERAGING_FILTER_SAMPLES; counter1++)
         {
            range+=srf08_ping(SRF08_CENTIMETERS);
         } 
       range /= AVERAGING_FILTER_SAMPLES;

       /* AUTOMATIC GAIN CONTROL (SLOW ATTACK, FAST RELEASE) */
       if(srf08_read_register(SRF08_ECHO_5) > 0 )
        { 
           if(gain>=5) { srf08_set_gain(gain-=5); } else { srf08_set_gain(gain=0); }  
        } 
       else if(srf08_read_register(SRF08_ECHO_2)<=0 && gain<31) { srf08_set_gain(++gain); } 

       /* DISPLAY TO LCD */
       lcd_gotoxy(14,0); lcd_puti(range,2);
       lcd_gotoxy(14,1); lcd_put_i(srf08_read_register(SRF08_ECHO_2), 2,4);
       lcd_gotoxy(14,2); lcd_put_i(srf08_read_register(SRF08_ECHO_5), 2,4);
       lcd_gotoxy(14,3); lcd_put_i(srf08_read_register(SRF08_LIGHT),2,4);


    }

return;
}