-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathversion.cpp
More file actions
31 lines (26 loc) · 886 Bytes
/
version.cpp
File metadata and controls
31 lines (26 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* Flybrix Flight Controller -- Copyright 2018 Flying Selfie Inc. d/b/a Flybrix
*
* http://www.flybrix.com
*/
#include "version.h"
#include "debug.h"
#include "led.h"
bool Version::verify() const {
if (major == FIRMWARE_VERSION_A && minor == FIRMWARE_VERSION_B && patch == FIRMWARE_VERSION_C) {
return true;
}
DebugPrint("Configuration versions do not match");
return false;
}
uint32_t encode(uint32_t color) {
bool lighter{color & 8};
uint32_t strength{lighter ? 0xcc : 0x11};
uint32_t base{lighter ? 0x010101 : 0x000000};
return (((color & 4) >> 2) + ((color & 2) << 7) + ((color & 1) << 16)) * strength + base;
}
void Version::display(LED& led) const {
led.set(LEDPattern::SOLID, encode(minor), 0, encode(major), encode(patch), false, false);
led.update();
led.set(LEDPattern::NO_OVERRIDE, 0, false, false);
}