void usb_hid_com_report_out_received(uint8_t *data) { // Mapped received data to report out type struct hid_report_out *report_out=(struct hid_report_out*)data; // Update LEDs with new report value ui_led(report_out->leds); // Load contrast value ui_set_contrast(report_out->contrast); // Set Backlight level ui_set_backlight(report_out->backlight<<8); // Display test user message if requested if (report_out->lcd_notify & 0x01) { ui_display_text(report_out->lcd_user_text, LCD_TEXT_STRING_SIZE); main_notify_external_msg(); } // Display numeric user message if requested if (report_out->lcd_notify & 0x02) { ui_display_sensor(report_out->lcd_user_num, UI_UNIT_NONE); main_notify_external_msg(); } }
void main_sof_action(void) { // LCD strings for on-board sensors static uint8_t lcd_txt_light[LCD_TEXT_STRING_SIZE + 2 * LCD_TEST_DISPLAY_SIZE] = "LIGHT SENSOR "; static uint8_t lcd_txt_ntc[LCD_TEXT_STRING_SIZE + 2 * LCD_TEST_DISPLAY_SIZE] = "TEMPERATURE SENSOR "; static uint8_t lcd_txt_pot[LCD_TEXT_STRING_SIZE + 2 * LCD_TEST_DISPLAY_SIZE] = "POTENTIOMETER INPUT "; static uint8_t lcd_txt_ext_v[LCD_TEXT_STRING_SIZE + 2 * LCD_TEST_DISPLAY_SIZE] = "EXTERNAL VOLTAGE "; static uint8_t old_button; if (main_timeout_user_message) { // Currently LCD is busy displaying user message from USB // Wait end of timeout to display again sensor message if (--main_timeout_user_message == 0) { switch (main_sensor_selected) { case LIGHT_SENSOR: ui_display_text(lcd_txt_light, sizeof(lcd_txt_light)); break; case TEMPERATURE_SENSOR: ui_display_text(lcd_txt_ntc, sizeof(lcd_txt_ntc)); break; case POTENTIOMETER_SENSOR: ui_display_text(lcd_txt_pot, sizeof(lcd_txt_pot)); break; case EXT_VOLTAGE_INPUT: ui_display_text(lcd_txt_ext_v, sizeof(lcd_txt_ext_v)); default: break; } } } // Change LOCAL text display when a button is pressed... if (old_button!=ui_button()) { old_button=ui_button(); if (ui_pusb_button_0()) { ui_display_text(lcd_txt_light, sizeof(lcd_txt_light)); main_sensor_selected = LIGHT_SENSOR; } if (ui_pusb_button_1()) { ui_display_text(lcd_txt_ntc, sizeof(lcd_txt_ntc)); main_sensor_selected = TEMPERATURE_SENSOR; } if (ui_pusb_button_2()) { ui_display_text(lcd_txt_pot, sizeof(lcd_txt_pot)); main_sensor_selected = POTENTIOMETER_SENSOR; } if (ui_pusb_button_3()) { ui_display_text(lcd_txt_ext_v, sizeof(lcd_txt_ext_v)); main_sensor_selected = EXT_VOLTAGE_INPUT; } // If hid generic interface is not up and running, do nothing if (!main_b_generic_enable) { return; } } // Prepare new report each HID_SEND_REPORT_MS ms if ((udd_get_frame_number() % HID_SEND_REPORT_MS) == 0) { usb_hid_com_send_report_in(); } // Prepare new ADC samples each ADC_NEW_SAMPLE_MS ms if ((udd_get_frame_number() % ADC_NEW_SAMPLE_MS) == 0) { adc_sensors_start_conversions(); } // Each LCD_SCROLLING_MS ms Performs LCD scrolling if ((udd_get_frame_number() % LCD_SCROLLING_MS) == 0) { ui_scroll_text(); } // Refresh on-board sensors LCD display // each LCD_SENSOR_MS and if no user message is displayed if (((udd_get_frame_number() % LCD_SENSOR_MS) == 0) && (main_timeout_user_message == 0)) { switch (main_sensor_selected) { case LIGHT_SENSOR: ui_display_sensor(adc_sensor_get_light(), UI_UNIT_NONE); break; case TEMPERATURE_SENSOR: ui_display_sensor(adc_sensor_get_temperature(), UI_UNIT_DEGREE_C); break; case POTENTIOMETER_SENSOR: ui_display_sensor(adc_sensor_get_potentiometer(), UI_UNIT_MILIVOLT); break; case EXT_VOLTAGE_INPUT: ui_display_sensor(adc_sensor_get_ext_voltage(), UI_UNIT_MILIVOLT); default: break; } } }