void main_sec(void) { backlightInit(); //disable the JTAG on PIO3_3 IOCON_PIO3_3 = 0x10; int yctr=8; int dx=0; font_direction = FONT_DIR_LTR; // LeftToRight is the default yctr=18; uint8_t trigger; trigger=20; uint32_t ctr=0; char key; while (1) { ctr++; lcdDisplay(0); delayms(10); key= getInput(); if(key==BTN_UP){ trigger +=1; }else if (key ==BTN_DOWN){ trigger -=1; }; font=&Font_7x8; dx=DoString(0,0,"Trig:"); dx=DoInt(dx,0,trigger); DoString(dx,0," "); // Easy flashing if(key==BTN_LEFT){ DoString(0,8,"Enter ISP!"); lcdDisplay(0); ISPandReset(5); }; // Display nickname font = &Font_Ubuntu36pt; dx=DoString(0,0,"Sec"); // Blink LED if(ctr++>trigger){ ctr=0; if (gpioGetValue(RB_LED2) == CFG_LED_OFF){ gpioSetValue (RB_LED2, CFG_LED_ON); } else { gpioSetValue (RB_LED2, CFG_LED_OFF); }; }; // Print Voltage font = &Font_7x8; dx=DoString(0,yctr+28,"Voltage:"); DoInt(dx,yctr+28,GetVoltage()); } return; }
float DropSensor::GetPosition() { return GetVoltage() * kVoltsToPosition; }
float AnalogUltrasonic::getDistance() { return GetVoltage()/.009765; }
static uint8_t mainloop() { uint32_t volatile oldCount = BusIntCtr; uint32_t loopCount=BusIntCtr; perMin = 0; // counts in last 60 s uint32_t minuteTime = _timectr; startTime = minuteTime; uint8_t button; //usbHIDInit(); while (1) { LED_OFF; if (loopCount != BusIntCtr) { loopCount=BusIntCtr; LED_ON; IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_GPIO; gpioSetDir(RB_LED3,gpioDirection_Output ) ; gpioSetValue(RB_LED3, 1); if (!GLOBAL(positionleds) ) { gpioSetValue(RB_LED2,1); gpioSetValue(RB_LED0,1); } } else { if (gpioGetValue(RB_PWR_CHRG) || !GLOBALchargeled) { gpioSetDir(RB_LED3,gpioDirection_Input ); // only when not charging.. } if (!GLOBAL(positionleds) ) { gpioSetValue(RB_LED0,0); gpioSetValue(RB_LED2,0); } } lcdClear(); //lcdPrintln(" Geiger"); //lcdPrintln(" Counter"); memcpy(&lcdBuffer[RESX*RESY_B-sizeof(Header_Invers)],Header_Invers,sizeof(Header_Invers)); lcdPrintln(""); lcdPrintln(""); // #### for (int i = 0; i < (14 * (_timectr - minuteTime)) / (60 * 100); i++) { lcdPrint("#"); } lcdPrintln(""); lcdPrint(" "); lcdPrintInt(BusIntCtr); lcdPrint(" in "); lcdPrintInt((_timectr - startTime) / 100); lcdPrintln("s"); lcdPrint(" "); lcdPrintInt(perMin); lcdPrintln(" cpm"); { uint32_t equivalent = nanoSievertPerH(perMin)+5; // letzte stelle runden lcdPrint(" "); lcdPrintInt(equivalent / 1000); lcdPrint("."); lcdPrintInt((equivalent % 1000) / 100); lcdPrintInt((equivalent % 100) / 10); //lcdPrintInt((equivalent % 10)); lcdPrintln(" uSv/h"); } //getGeigerMeshVal(); lcdPrintln(""); if (gpioGetValue(RB_PWR_CHRG)){ uint32_t voltage=GetVoltage(); if (voltage >= GOOD_VOLTAGE) { lcdPrintln("Bat: [++++] "); } else if (voltage >= HALF_VOLTAGE) { lcdPrintln("Bat: [ooo ] "); } else if (voltage >= MIN_SAFE_VOLTAGE) { lcdPrintln("Bat: [== ] "); } else if (voltage >= CRIT_VOLTAGE) { lcdPrintln("Bat: [- ] L"); } else { lcdPrintln("Battery: CRIT!"); } } else { lcdPrintln("Bat: Charging"); } // remember: We have a 10ms Timer counter if ((minuteTime + 60 * 100) <= _timectr) { // dumb algo: Just use last 60 seconds count perMin = BusIntCtr - oldCount; minuteTime = _timectr; oldCount = BusIntCtr; //transmitGeigerMeshVal(perMin,minuteTime / (100)); } lcdRefresh(); delayms_queue_plus(42, 0); button = getInputRaw(); if (button != BTN_NONE) { break; } } //usbHidDisconnect(); return button; }
//-----------------------Private functions-----------------------------// static void pub_Perform( void ) { /*! Voltage level is transferred through DMA and read from AdcBufferTable */ oBattery.Voltage = priv_GetNewMean( (float)GetVoltage( AdcBufferTable[BatteryIndex] ) ); oBattery.ChargedPercent = (float)GetPercentFromVoltage( oBattery.Voltage ); }