Skip to content

Commit

Permalink
initrandom is now working in hardware
Browse files Browse the repository at this point in the history
  • Loading branch information
jonneva committed Apr 22, 2018
1 parent 0e3dbf2 commit 0873ee9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Pokitto/POKITTO_CORE/PokittoBattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ uint16_t Battery::voltage;
uint16_t Battery::thresholds[NUM_LVL];
uint8_t Battery::nextUpdate;

void Battery::begin() {
AnalogIn BatLevelPin(P0_23);

void Battery::begin() {
level = BatLevelPin*0xFF;
}

void Battery::update() {
//ToDo - make a real function
level=0xFF; //full battery all the time
level = BatLevelPin*0xFF;
}

4 changes: 3 additions & 1 deletion Pokitto/POKITTO_HW/PokittoHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ void Core::quit() {
}

void Core::initRandom() {
//TODO: hook random seed to battery level
time_t seconds = time(NULL);
Pokitto::Battery::update();
srand((unsigned int) (Pokitto::Battery::level + (seconds)));
}

void Core::initGPIO() {
Expand Down

0 comments on commit 0873ee9

Please sign in to comment.