예제 #1
0
파일: main.cpp 프로젝트: Kreyl/nute
void Init() {
    Uart.Init(115200);
    Uart.Printf("\rFirefly2\r");
    Led.Init();
    Led.SetColorSmoothly((Color_t){255, 255, 255});
    Adc.Init();
}
예제 #2
0
파일: main.cpp 프로젝트: Kreyl/WitcherGlove
// =============================== Init ========================================
static inline void ShowChargeLevel() {
    Adc_t Adc;
    uint32_t rslt = 0;
    Adc.Init();
    for(uint8_t i=0; i<8; i++) {
        Adc.StartConversion();
        while(!Adc.ConversionCompleted()) chThdSleepMilliseconds(20);
        rslt += Adc.Result();
    }
    Adc.Disable();
    Adc.ClockOff();
    rslt >>= 3;
    rslt = (rslt * 16225) / 10000;
    Uart.Printf("mv=%u\r", rslt);
    // Show charge
    BlueLed.On(LED_LOW);    // Always
    if(rslt > 3700) RedLed.On   (LED_LOW);
    if(rslt > 3800) YellowLed.On(LED_LOW);
    if(rslt > 3900) GreenLed.On (LED_LOW);
    if(rslt > 4050) WhiteLed.On (LED_LOW);
}