float IRTemp::getIRTemperature( TempUnit scale) { return(getTemperature(scale, IRTEMP_DATA_IR)); }
float IRTemp::getAmbientTemperature( TempUnit scale) { return(getTemperature(scale, IRTEMP_DATA_AMBIENT)); }
int CurieImuClass::readTemperature() { return getTemperature(); }
void menuStatisticsDebug(uint8_t event) { TITLE(STR_MENUDEBUG); switch(event) { #if defined(CPUARM) case EVT_KEY_LONG(KEY_ENTER): g_eeGeneral.mAhUsed = 0; g_eeGeneral.globalTimer = 0; eeDirty(EE_GENERAL); #if defined(PCBSKY9X) Current_used = 0; #endif sessionTimer = 0; killEvents(event); AUDIO_KEYPAD_UP(); break; #endif case EVT_KEY_FIRST(KEY_ENTER): #if !defined(CPUARM) g_tmr1Latency_min = 0xff; g_tmr1Latency_max = 0; #endif #if defined(LUA) maxLuaInterval = 0; maxLuaDuration = 0; #endif maxMixerDuration = 0; AUDIO_KEYPAD_UP(); break; case EVT_KEY_FIRST(KEY_DOWN): chainMenu(menuStatisticsView); return; case EVT_KEY_FIRST(KEY_EXIT): chainMenu(menuMainView); return; } #if defined(PCBSKY9X) if ((ResetReason&RSTC_SR_RSTTYP) == (2<<8)) { lcd_puts(LCD_W-8*FW, 0*FH, "WATCHDOG"); } else if (unexpectedShutdown) { lcd_puts(LCD_W-13*FW, 0*FH, "UNEXP.SHTDOWN"); } #endif #if defined(PCBSKY9X) && !defined(REVA) // current lcd_putsLeft(MENU_DEBUG_Y_CURRENT, STR_CPU_CURRENT); putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_CURRENT, getCurrent(), UNIT_MILLIAMPS, LEFT); uint32_t current_scale = 488 + g_eeGeneral.currentCalib; lcd_putc(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_CURRENT, '>'); putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CURRENT, Current_max*10*current_scale/8192, UNIT_RAW, LEFT); // consumption lcd_putsLeft(MENU_DEBUG_Y_MAH, STR_CPU_MAH); putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MAH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1); #endif #if defined(PCBSKY9X) lcd_putsLeft(MENU_DEBUG_Y_CPU_TEMP, STR_CPU_TEMP); putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_CPU_TEMP, getTemperature(), UNIT_TEMPERATURE, LEFT); lcd_putc(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_CPU_TEMP, '>'); putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CPU_TEMP, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT); #endif #if defined(COPROCESSOR) lcd_putsLeft(MENU_DEBUG_Y_COPROC, STR_COPROC_TEMP); if (Coproc_read==0) { lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Co Proc NACK"),INVERS); } else if (Coproc_read==0x81) { lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Inst.TinyApp"),INVERS); } else if (Coproc_read<3) { lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Upgr.TinyApp"),INVERS); } else { putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, Coproc_temp, UNIT_TEMPERATURE, LEFT); putsTelemetryValue(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_COPROC, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT); } #endif #if defined(PCBTARANIS) && !defined(SIMU) lcd_putsLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem"); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, getAvailableMemory(), LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_FREE_RAM, "b"); #endif #if defined(LUA) lcd_putsLeft(MENU_DEBUG_Y_LUA, "Lua scripts"); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT); #endif #if defined(CPUARM) lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms"); #endif #if 0 lcd_putsLeft(MENU_DEBUG_Y_STACK, STR_FREESTACKMINB); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_STACK, stack_free(255), UNSIGN|LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_STACK, "b"); #endif #if defined(PCBTARANIS) lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[Main]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(0), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[Mix]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(1), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[Audio]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(2), UNSIGN|LEFT); #endif #if defined(PCBSKY9X) lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS, stack_free(0), UNSIGN|LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_RTOS, "/"); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(1), UNSIGN|LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_RTOS, "/"); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(2), UNSIGN|LEFT); #endif #if !defined(CPUARM) lcd_putsLeft(1*FH, STR_TMR1LATMAXUS); lcd_outdez8(MENU_DEBUG_COL1_OFS , 1*FH, g_tmr1Latency_max/2 ); lcd_putsLeft(2*FH, STR_TMR1LATMINUS); lcd_outdez8(MENU_DEBUG_COL1_OFS , 2*FH, g_tmr1Latency_min/2 ); lcd_putsLeft(3*FH, STR_TMR1JITTERUS); lcd_outdez8(MENU_DEBUG_COL1_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 ); lcd_putsLeft(4*FH, STR_TMIXMAXMS); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 4*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2); lcd_putsLeft(5*FH, STR_FREESTACKMINB); lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ; #endif lcd_puts(3*FW, 7*FH+1, STR_MENUTORESET); lcd_status_line(); }
int main(void) { TFT_Setup(); //Set up the TFT LCD setupSensorian(); //Set up all the sensors on the Sensorian Shield orange_led_on(); //Turn on the Sensorian Orange LED printf("Light: %f\n", getAmbientLight()); //Print the current light level pollMPL(); //Poll the sensor for the current temperature, altitude and pressure printf("Temperature: %d\n", getTemperature()); //Print the last polled temperature printf("Altitude: %d\n", getAltitude()); //Print the last polled altitude printf("Pressure: %d\n", getBarometricPressure()); //Print the last polled pressure pollFXOS(); //Poll the sensor for the current accelerometer and magnetometer values printf("Magnetometer X: %d, Y: %d, Z: %d\n", getMagX(), getMagY(), getMagZ()); //Print last polled magnet values printf("Accelerometer X: %d, Y: %d, Z: %d\n", getAccelX(), getAccelY(), getAccelZ()); //Print last accel values poll_rtcc(); //Poll the real time clock to get the current date and time printf("Date (DD/MM/YY): %d, %d, %d\n", get_rtcc_date(), get_rtcc_month(), get_rtcc_year()); //Print the date printf("Time: %d:%d:%d\n", get_rtcc_hour(), get_rtcc_minute(), get_rtcc_second()); //Print the last polled time //Create a sample string/char array to print to the screen char s[] = "This is a long string that will wrap with the display to fit if possible."; printf("Print Test\n"); TFT_Printer_Print(s); //Print the string to the screen with the default settings sleep(1); printf("Print Color Test\n"); TFT_Printer_PrintColor(RED, GREEN, s); //Print the string to the screen, changing the color sleep(1); printf("Print Size Test\n"); TFT_Printer_PrintSize(s, 2); //Print the string to the screen, changing the size sleep(1); printf("Print Both Test\n"); TFT_Printer_PrintBoth(YELLOW, BLUE, s, 3); //Print the string to the screen changing the color and size sleep(1); printf("Print All Test\n"); TFT_Printer_PrintAll(PORTRAIT, WHITE, BLACK, s, 2); //Print the string to the screen, changing color, sleep(1); //size and the orientation printf("Print Test 2\n"); TFT_Printer_Print(s); //Print the string to the screen again, using the last settings applied sleep(1); char ip_address[16] = {0}; //Creates a buffer in which to store the interface IP pi_get_interface_ip(ip_address); //Passes the buffer to the function which gets the interface IP char public_ip[16] = {0}; //Creates a buffer in which to store the public IP cloud_get_public_ip(public_ip); //Passes the buffer to the function which gets the public IP char ips_printed[57]; //Create a char array in which to store the string to be printed to the LCD strcpy(ips_printed, "Interface IP: "); //Start the new string off with the label Interface IP strcat(ips_printed, ip_address); //Add the string containing the temperature to the end of the string strcat(ips_printed, " Public IP: "); //Add the label Public IP to the end of the string strcat(ips_printed, public_ip); //Add the string containing the public ip to the end of the string TFT_Printer_PrintAll(LANDSCAPE_INV, WHITE, BLACK, ips_printed, 2); //Prints both IP addresses to the LCD sleep(1); char *key = "YourIFTTTMakerChannelKey"; //Create a string for your IFTTT Maker Channel Key char *event = "YourRecipeEventName"; //Create a string for your IFTTT Maker Channel Event long timeout = 5; //Create a long for the number of seconds to wait before timing out the request cloud_ifttt_trigger(key, event, timeout); //Send a HTTP request to trigger an IFTTT Maker Channel Recipe //Send a HTTP request to trigger an IFTTT Maker Channel Recipe along with 3 values in a JSON cloud_ifttt_trigger_values(key, event, timeout, "Value1", "2", "3.0"); float cpu_temp = pi_get_cpu_temperature(); //Store the float of the CPU temperature returned by the function char cpu_temp_str[10]; //Create a char array in which to store the string equivalent of the temperature sprintf(cpu_temp_str, "%f", cpu_temp); //Convert the CPU temperature float to a char array and store it char cpu_temp_printed[20]; //Create a char array in which to store the string to be printed to the LCD strcpy(cpu_temp_printed, "CPU TEMP: "); //Start the new string off with the label CPU TEMP strcat(cpu_temp_printed, cpu_temp_str); //Add the string containing the temperature to the end of the string TFT_Printer_PrintAll(LANDSCAPE_INV, WHITE, BLACK, cpu_temp_printed, 2); //Prints CPU Temperature to the LCD sleep(1); char cpu_serial[17] = {0}; //Creates a buffer in which to store the CPU serial pi_get_cpu_serial(cpu_serial); //Passes the buffer to the function which gets the CPU Serial char cpu_serial_printed[29]; //Create a char array in which to store the string to be printed to the LCD strcpy(cpu_serial_printed, "CPU SERIAL: "); //Start the new string off with the label CPU SERIAL strcat(cpu_serial_printed, cpu_serial); //Add the string containing the serial to the end of the string TFT_Printer_PrintAll(LANDSCAPE_INV, WHITE, BLACK, cpu_serial_printed, 1); //Prints CPU serial to the LCD sleep(1); orange_led_off(); //Turn off the Sensorian Orange LED //printf("Rebooting\n"); //pi_reboot(5); //Reboots the Raspberry Pi in the given number of seconds without blocking program execution return 0; //End the program }