⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emeter-basic-display.c

📁 msp430F437三相电表DEMO(编译器 IAR 3.42A)
💻 C
📖 第 1 页 / 共 3 页
字号:
    LCDicon(ICON_DATE_COLON_1, TRUE);
            #endif
            #if defined(ICON_DATE_COLON_1A)
    LCDicon(ICON_DATE_COLON_1A, TRUE);
            #endif
            #if defined(ICON_DATE_COLON_2)
    LCDicon(ICON_DATE_COLON_2, TRUE);
            #endif
            #if defined(ICON_DATE_COLON_2A)
    LCDicon(ICON_DATE_COLON_2A, TRUE);
            #endif
            #if defined(ICON_DATE)
    LCDicon(ICON_DATE, TRUE);
            #endif
}

static __inline__ void display_current_time(void)
{
            #if defined(DEDICATED_TIME_FIELD)
    uint8_t x;

    /*TODO: This is fudged, as the time field has digits in
            reverse order from the main field. */
    LCDdecu16(rtc.hour, DEDICATED_TIME_FIELD + 2, 2, 1);
    LCDdecu16(rtc.minute, DEDICATED_TIME_FIELD, 2, 1);
    x = LCDMEM[12];
    LCDMEM[12] = LCDMEM[11];
    LCDMEM[11] = x;
    x = LCDMEM[14];
    LCDMEM[14] = LCDMEM[13];
    LCDMEM[13] = x;
                #if defined(ICON_TIME_FIELD_TIME)
    LCDicon(ICON_TIME_FIELD_TIME, TRUE);
                #endif
                #if defined(ICON_TIME_FIELD_COLON)
    LCDicon(ICON_TIME_FIELD_COLON, TRUE);
                #endif
            #elif defined(TWO_LINE_LCD)
                #if defined(ZAP_COLON_CELL)
    LCDchar(CHAR_SPACE, ZAP_COLON_CELL);
                #endif
    LCDdecu16(rtc.hour, HOUR_POSITION, 2, 1);
    LCDdecu16(rtc.minute, MINUTE_POSITION, 2, 1);
    LCDdecu16(rtc.second, SECONDS_POSITION, 2, 1);
                #if defined(ICON_TIME_COLON_1)
    LCDicon(ICON_TIME_COLON_1, TRUE);
                #endif
                #if defined(ICON_TIME_COLON_1A)
    LCDicon(ICON_TIME_COLON_1A, TRUE);
                #endif
                #if defined(ICON_TIME_COLON_2)
    LCDicon(ICON_TIME_COLON_2, TRUE);
                #endif
                #if defined(ICON_TIME_COLON_2A)
    LCDicon(ICON_TIME_COLON_2A, TRUE);
                #endif
                #if defined(ICON_TIME)
    LCDicon(ICON_TIME, TRUE);
                #endif
            #else
                #if !defined(ICON_TIME)  &&  defined(DISPLAY_TYPE_POSITION)
                    #if defined(USE_STARBURST)
    LCDchar(CHAR_T, DISPLAY_TYPE_POSITION);
                    #else
    LCDchar(CHAR_t, DISPLAY_TYPE_POSITION);
                    #endif
                    #if FIRST_POSITION > 2
    LCDchar(CHAR_i, DISPLAY_TYPE_POSITION + 1);
                    #endif
                #endif
                #if defined(ZAP_COLON_CELL)
    LCDchar(CHAR_SPACE, ZAP_COLON_CELL);
                #endif
    LCDdecu16(rtc.hour, HOUR_POSITION, 2, 1);
    LCDdecu16(rtc.minute, MINUTE_POSITION, 2, 1);
    LCDdecu16(rtc.second, SECONDS_POSITION, 2, 1);
                #if defined(ICON_TIME_COLON_1)
    LCDicon(ICON_TIME_COLON_1, TRUE);
                #endif
                #if defined(ICON_TIME_COLON_1A)
    LCDicon(ICON_TIME_COLON_1A, TRUE);
                #endif
                #if defined(ICON_TIME_COLON_2)
    LCDicon(ICON_TIME_COLON_2, TRUE);
                #endif
                #if defined(ICON_TIME_COLON_2A)
    LCDicon(ICON_TIME_COLON_2A, TRUE);
                #endif
                #if defined(ICON_TIME)
    LCDicon(ICON_TIME, TRUE);
                #endif
            #endif
}
        #endif

        #if defined(TEMPERATURE_SUPPORT)
static __inline__ void display_temperature(void)
{
    int32_t temp;

    LCDchar(CHAR_C, DISPLAY_TYPE_POSITION);
    /* Convert the temperature reading to degrees C */
    /* DegC = ((((int32_t) ADC_result - 1615)*704)/4095); */
    /* We filtered in a way that multiplied the temperature reading by 8 */
    /* Therefore, to get a result in 0.1 degree C steps we do this... */
    temp = temperature - nv_parms.seg_a.s.temperature_offset;
    temp *= nv_parms.seg_a.s.temperature_scaling;
    temp >>= 16;
    LCDdec32(temp, FIRST_TEMPERATURE_POSITION, NUMBER_WIDTH - 1, 1);
}
        #endif

        #if defined(MULTI_RATE_SUPPORT)
void display_current_tariff(void)
{
            #if !defined(ICON_DATE)  &&  defined(DISPLAY_TYPE_POSITION)
                #if defined(USE_STARBURST)
    LCDchar(CHAR_T, DISPLAY_TYPE_POSITION);
                #else
    LCDchar(CHAR_t, DISPLAY_TYPE_POSITION);
                #endif
    LCDchar(CHAR_a, DISPLAY_TYPE_POSITION + 1);
    LCDchar(CHAR_r, DISPLAY_TYPE_POSITION + 2);
    LCDchar(CHAR_r, DISPLAY_TYPE_POSITION + 3);
    LCDchar(CHAR_SPACE, DISPLAY_TYPE_POSITION + 4);
            #endif
    LCDdecu16(current_tariff + 1, DISPLAY_TYPE_POSITION + 5, 2, 0);
}

void display_tariff_holiday(void)
{
    int i;
    eeprom_holiday_t holiday;

    info_step = 0;
    for (i = info_step;  i < MULTIRATE_MAX_HOLIDAYS;  i++)
    {
        iicEEPROM_read(EEPROM_START_HOLIDAYS + i*sizeof(eeprom_holiday_t), (void *) &holiday, sizeof(holiday));
        if (holiday.year)
        {
            info_step = i;
            #if !defined(ICON_DATE)  &&  defined(DISPLAY_TYPE_POSITION)
                #if defined(USE_STARBURST)
            LCDchar(CHAR_D, DISPLAY_TYPE_POSITION);
                #else
            LCDchar(CHAR_d, DISPLAY_TYPE_POSITION);
                #endif
                #if FIRST_POSITION > 2
            LCDchar(CHAR_t, DISPLAY_TYPE_POSITION + 1);
                #endif
            #endif
            #if defined(ZAP_COLON_CELL)
            LCDchar(CHAR_SPACE, ZAP_COLON_CELL);
            #endif
            LCDdecu16(holiday.year, YEAR_POSITION, 2, 1);
            LCDdecu16(holiday.month, MONTH_POSITION, 2, 1);
            LCDdecu16(holiday.day, DAY_POSITION, 2, 1);
            #if defined(ICON_COLON_1)
            LCDicon(ICON_COLON_1, TRUE);
            #endif
            #if defined(ICON_COLON_1A)
            LCDicon(ICON_COLON_1A, TRUE);
            #endif
            #if defined(ICON_COLON_2)
            LCDicon(ICON_COLON_2, TRUE);
            #endif
            #if defined(ICON_COLON_2A)
            LCDicon(ICON_COLON_2A, TRUE);
            #endif
            #if defined(ICON_DATE)
            LCDicon(ICON_DATE, TRUE);
            #endif
            return;
        }
    }
}
        #endif

void update_display(void)
{
    int skip_stage;
        #if !defined(SINGLE_PHASE)
    struct phase_parms_s *phase;
    struct phase_nv_parms_s const *phase_nv;

    phase = &chan[(int) display_phase];
    phase_nv = &nv_parms.seg_a.s.chan[(int) display_phase];
        #endif
    do
    {
        skip_stage = FALSE;
        LCDchar(CHAR_SPACE, DISPLAY_TYPE_POSITION);
        #if defined(ICON_ONLY_1)
        LCDchar(0, ICON_ONLY_1);
        #endif
        #if defined(ICON_ONLY_2)
        LCDchar(0, ICON_ONLY_2);
        #endif
        #if defined(ICON_ONLY_3)
        LCDchar(0, ICON_ONLY_3);
        #endif
        #if defined(PHASE_POSITION)
            #if defined(SINGLE_PHASE)
        LCDchar(CHAR_SPACE, PHASE_POSITION);
            #else
        if (display_stage <= DISPLAY_STAGE_PHASE_LAST)
            LCDdecu16(display_phase + 1, PHASE_POSITION, 1, 0);
        else
            LCDchar(CHAR_SPACE, PHASE_POSITION);
            #endif
        #endif
        display_clear_line_1();
        #if defined(TWO_LINE_LCD)
        display_clear_line_2();
        #endif
        switch (display_stage)
        {
        #if defined(PER_PHASE_ENERGY_SUPPORT)
        case DISPLAY_STAGE_PHASE_ENERGY:
            #if defined(SINGLE_PHASE)
            display_phase_consumed_energy();
            #else
            display_phase_consumed_energy(phase);
            #endif
            #if !defined(TWO_LINE_LCD)
            break;
        case DISPLAY_STAGE_PHASE_POWER:
            #endif
            #if defined(SINGLE_PHASE)
            display_phase_power();
            #else
            display_phase_power(phase);
            #endif
            break;
        #endif
        #if defined(MAINS_FREQUENCY_SUPPORT)
        case DISPLAY_STAGE_MAINS_FREQUENCY:
            #if defined(SINGLE_PHASE)
            display_mains_frequency();
            #else
            display_mains_frequency(phase);
            #endif
            break;
        #endif
        #if defined(IRMS_SUPPORT)
        case DISPLAY_STAGE_CURRENT:
            #if defined(SINGLE_PHASE)
            display_irms();
            #else
            display_irms(phase, phase_nv);
            #endif
            break;
        #endif
        #if defined(VRMS_SUPPORT)
        case DISPLAY_STAGE_VOLTAGE:
            #if defined(SINGLE_PHASE)
            display_vrms();
            #else
            display_vrms(phase, phase_nv);
            #endif
            break;
        #endif
        #if defined(IRMS_SUPPORT)  &&  defined(VRMS_SUPPORT)  &&  defined(POWER_FACTOR_SUPPORT)
        case DISPLAY_STAGE_POWER_FACTOR:
            #if defined(SINGLE_PHASE)
            display_power_factor();
            #else
            display_power_factor(phase, phase_nv);
            #endif
            break;
            #if defined(REACTIVE_POWER_SUPPORT)
        case DISPLAY_STAGE_REACTIVE_POWER:
                #if defined(SINGLE_PHASE)
            display_reactive_power();
                #else
            display_reactive_power(phase);
                #endif
            break;
            #endif
            #if defined(VA_POWER_SUPPORT)
        case DISPLAY_STAGE_VA:
                #if defined(SINGLE_PHASE)
            display_VA_power();
                #else
            display_VA_power(phase);
                #endif
            break;
            #endif
        #endif
    #endif
    #if defined(RTC_SUPPORT)
        case DISPLAY_STAGE_DATE:
            display_current_date();
        #if defined(TWO_LINE_LCD)
            display_current_time();
        #endif
            break;
        #if !defined(DEDICATED_TIME_FIELD)  &&  !defined(TWO_LINE_LCD)
        case DISPLAY_STAGE_TIME:
            display_current_time();
            break;
        #endif
    #endif
    #if !defined(SINGLE_PHASE)  &&  defined(NEUTRAL_MONITOR_SUPPORT)
        case DISPLAY_STAGE_NEUTRAL_CURRENT:
            display_neutral_irms();
            break;
    #endif
    #if defined(TEMPERATURE_SUPPORTx)
        case DISPLAY_STAGE_TEMPERATURE:
            display_temperature();
            break;
    #endif
    #if defined(MULTI_RATE_SUPPORT)
        case DISPLAY_STAGE_CURRENT_TARIFF:
            display_current_tariff();
            break;
    #endif
    #if defined(TOTAL_ENERGY_SUPPORT)
        case DISPLAY_STAGE_TOTAL_POWER:
            display_total_power();
        #if !defined(TWO_LINE_LCD)
            break;
        default:
        #endif
            display_total_consumed_energy();
            break;
    #endif
        }

    #if !defined(SINGLE_PHASE)  &&  defined(ICON_PHASE_A)  &&  defined(ICON_PHASE_B)  &&  defined(ICON_PHASE_C)
        if (display_stage <= DISPLAY_STAGE_PHASE_LAST)
        {
            //Turn on the appropriate cursor, to indicate the current phase
            LCDicon(phase_icons[0], display_phase == 0);
            LCDicon(phase_icons[1], display_phase == 1);
            LCDicon(phase_icons[2], display_phase == 2);
        }
        else
        {
            //Turn off the cursors, as we are not showing phase related info
            LCDicon(phase_icons[0], FALSE);
            LCDicon(phase_icons[1], FALSE);
            LCDicon(phase_icons[2], FALSE);
        }
        #if FIRST_POSITION > 2
        LCDchar(CHAR_SPACE, 2);
        #endif
    #endif

    #if defined(SINGLE_PHASE)
        if (++display_stage >= DISPLAY_STAGE_LAST) 
            display_stage = 0;
    #else
        if (display_phase < NUM_PHASES - 1)
        {
            if (++display_stage >= DISPLAY_STAGE_PHASE_LAST)
            {
                display_stage = 0;
                display_phase++;
            }
        }
        else
        {
            if (++display_stage == DISPLAY_STAGE_PHASE_LAST)
                display_stage++;
            if (display_stage >= DISPLAY_STAGE_LAST) 
            {
                display_stage = 0;
                display_phase = 0;
            }
        }
    #endif
    }
    while (skip_stage);
    #if defined(DEDICATED_TIME_FIELD)
    display_current_time();
    #endif
    #if defined(ICON_BATTERY)
    LCDicon(ICON_BATTERY, TRUE);
    #endif
    #if LIMP_MODE_SUPPORT
    if (operating_mode == OPERATING_MODE_LIMP)
        LCDchar(CHAR_L, DISPLAY_TYPE_POSITION);
    #endif
}

#if !defined(__GNUC__)
int16_t ram_exclusion_zone_start_;
int16_t ram_exclusion_zone_middle_;
int16_t ram_exclusion_zone_end_;
#endif

#endif

#if defined(__MSP430__)
    #if defined(BASIC_KEYPAD_SUPPORT)
void keypad_handler(void)
{
    if ((key_states & KEY_1_DOWN))
    {
        update_display();
        key_states &= ~KEY_1_DOWN;
    }
    if ((key_states & KEY_1_REPEAT_DOWN))
    {
        update_display();
        key_states &= ~KEY_1_REPEAT_DOWN;
    }
}
    #endif
#endif

#if 0
    switch (info_section)
    {
    case 0:
        info_substep
        if (++info_step >= MULTIRATE_TARIFFS)
        {
            info_section++;
            info_step = 0;
        }
        break;
    case 1:
        if (++info_step >= MULTIRATE_MAX_HOLIDAYS)
        {
            info_section++;
            info_step = 0;
        }
        break;
    case 2:
        if (++info_step >= MULTIRATE_MAX_CUTOFF_DATES)
        {
            info_section++;
            info_step = 0;
        }
        break;
    case 3:
        if (++info_step >= MULTIRATE_HISTORIES)
        {
            info_section++;
            info_step = 0;
        }
        break;
    case 4:
        if (++info_step >= MULTIRATE_MAX_DAILY_PEAKS)
        {
            info_section++;
            info_step = 0;
        }
        break;
    }
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -