Compare commits
5 Commits
2e5caea417
...
141aee7066
| Author | SHA1 | Date | |
|---|---|---|---|
| 141aee7066 | |||
| 409e78300d | |||
| 4c5d68d1ab | |||
| d364497804 | |||
| e7f436118f |
BIN
manufacturing/programming/STM32_Programmer_CLI
Executable file
BIN
manufacturing/programming/STM32_Programmer_CLI
Executable file
Binary file not shown.
BIN
manufacturing/programming/firmware_v21_20211024.bin
Executable file
BIN
manufacturing/programming/firmware_v21_20211024.bin
Executable file
Binary file not shown.
BIN
manufacturing/programming/firmware_v21_20211028.bin
Executable file
BIN
manufacturing/programming/firmware_v21_20211028.bin
Executable file
Binary file not shown.
@@ -1,2 +1,13 @@
|
||||
#!/bin/bash
|
||||
/Applications/STMicroelectronics/STM32Cube/STM32_Programmer_CLI -c port=SWD -e all -w /Users/willem/Documents/PROJECTS/Leo-led-truck/manufacturing/programming/firmware20210720_short.bin 0x08000000 -ob RDP=0xBB
|
||||
TOOLPATH="/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin"
|
||||
|
||||
|
||||
$TOOLPATH/STM32_Programmer_CLI -c port=SWD -ob RDP=0xAA
|
||||
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
echo "Failed to set Optiobytes, EXIT!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$TOOLPATH/STM32_Programmer_CLI -c port=SWD -e all -w firmware_v21_20211028.bin 0x08000000 -ob RDP=0xBB
|
||||
3
manufacturing/programming/unlockOB.sh
Executable file
3
manufacturing/programming/unlockOB.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
/Applications/STMicroelectronics/STM32Cube/STM32_Programmer_CLI -c port=SWD -ob RDP=0xAA
|
||||
/Applications/STMicroelectronics/STM32Cube/STM32_Programmer_CLI -c port=SWD -e all
|
||||
97
src/game.cpp
97
src/game.cpp
@@ -4,26 +4,37 @@
|
||||
#include "simpleled.h"
|
||||
#include "magicSwitchBoard.h"
|
||||
#include "chainGame.h"
|
||||
#include "detectled.h"
|
||||
//#include "detectled.h"
|
||||
|
||||
std::vector<c_game *> gameslist;
|
||||
uint64_t GameSelectTimer = 0;
|
||||
e_state currentState = state_init;
|
||||
bool gamesConstructed = false;
|
||||
|
||||
c_game *game_simpleled = new c_simpleLed(YELLOW);
|
||||
c_game *game_magicswitchboard = new c_magicSwitchBoard(RED);
|
||||
c_game *game_chaingame = new c_chaingame(GREEN);
|
||||
c_game *game_detectled = new c_detectled(NONE);
|
||||
// c_game *game_detectled = new c_detectled(NONE);
|
||||
|
||||
void setGameState(e_state newstate);
|
||||
void constructGames(void);
|
||||
|
||||
void initGames(void)
|
||||
{
|
||||
gameslist.clear();
|
||||
gameslist.push_back(game_simpleled);
|
||||
gameslist.push_back(game_magicswitchboard);
|
||||
gameslist.push_back(game_chaingame);
|
||||
gameslist.push_back(game_detectled);
|
||||
constructGames();
|
||||
setGameState(state_init);
|
||||
}
|
||||
|
||||
activateGame(simpleled);
|
||||
void constructGames(void)
|
||||
{
|
||||
if (!gamesConstructed)
|
||||
{
|
||||
gameslist.clear();
|
||||
gameslist.push_back(game_simpleled);
|
||||
gameslist.push_back(game_magicswitchboard);
|
||||
gameslist.push_back(game_chaingame);
|
||||
gamesConstructed = true;
|
||||
}
|
||||
}
|
||||
|
||||
c_game *getGame(e_game game)
|
||||
@@ -135,14 +146,14 @@ void HandleGameSelectTimeout(void)
|
||||
// yellow && red && green all on
|
||||
if (allButtons())
|
||||
{
|
||||
//all buttons pressed, wait for next game
|
||||
// all buttons pressed, wait for next game
|
||||
if (!GameSelectTimer)
|
||||
{
|
||||
GameSelectTimer = currentmillis;
|
||||
}
|
||||
else
|
||||
{
|
||||
//check timeout
|
||||
// check timeout
|
||||
if (currentmillis - GameSelectTimer > GAMESELECTTIMEOUT)
|
||||
{
|
||||
currentState = state_idle;
|
||||
@@ -152,7 +163,7 @@ void HandleGameSelectTimeout(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
//no gameselect sequence initiated
|
||||
// no gameselect sequence initiated
|
||||
GameSelectTimer = currentmillis;
|
||||
}
|
||||
}
|
||||
@@ -160,29 +171,36 @@ void HandleGameSelectTimeout(void)
|
||||
void HandleGameIdle(void)
|
||||
{
|
||||
e_game nextGame = none;
|
||||
if(!gamesConstructed)
|
||||
{
|
||||
initGames();
|
||||
}
|
||||
|
||||
for (auto &&thisgame : gameslist)
|
||||
{
|
||||
if (onlyButton(thisgame->getGameColor()) && (nextGame == none))
|
||||
{
|
||||
//prepare for next game
|
||||
// prepare for next game
|
||||
nextGame = thisgame->getIndex();
|
||||
turnOffLed(thisgame->getGameColor());
|
||||
turnOnLed(thisgame->getGameColor());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//wait for all buttons to be switched off
|
||||
// wait for all buttons to be switched off
|
||||
if (!anybutton())
|
||||
{
|
||||
activateGame(nextGame);
|
||||
currentState = state_play;
|
||||
if (nextGame != none)
|
||||
{
|
||||
activateGame(nextGame);
|
||||
setGameState(state_play);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setGameState(e_state newstate)
|
||||
{
|
||||
currentState = state_play;
|
||||
currentState = newstate;
|
||||
}
|
||||
|
||||
e_state getCurrentState(void)
|
||||
@@ -196,6 +214,24 @@ void handleGames(void)
|
||||
|
||||
switch (getCurrentState())
|
||||
{
|
||||
case state_init:
|
||||
{
|
||||
disableAllGames();
|
||||
setGameState(state_init);
|
||||
GameSelectTimer = 0;
|
||||
|
||||
if (anybutton())
|
||||
{
|
||||
setGameState(state_idle);
|
||||
}
|
||||
else
|
||||
{
|
||||
activateGame(simpleled);
|
||||
setGameState(state_play);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case state_idle:
|
||||
{
|
||||
HandleGameIdle();
|
||||
@@ -207,32 +243,9 @@ void handleGames(void)
|
||||
runGames();
|
||||
}
|
||||
break;
|
||||
|
||||
case state_init:
|
||||
default:
|
||||
{
|
||||
//delay(1000);
|
||||
turnOffAllLed();
|
||||
activateGame(simpleled);
|
||||
|
||||
for (auto &&thisgame : gameslist)
|
||||
{
|
||||
if (onlyButton(thisgame->getGameColor()))
|
||||
{
|
||||
//prepare for next game
|
||||
activateGame(thisgame->getIndex());
|
||||
turnOnLed(thisgame->getGameColor());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//wait for all buttons idle
|
||||
while (anybutton())
|
||||
{
|
||||
}
|
||||
|
||||
turnOffAllLed();
|
||||
setGameState(state_play);
|
||||
currentState = state_init;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,12 +48,15 @@ public:
|
||||
e_ledcolor getGameColor(void) { return _gamecolor; }
|
||||
};
|
||||
|
||||
e_game getActiveGame(void);
|
||||
c_game *getGame(e_game game, e_ledcolor gamecolor);
|
||||
void runGame(e_game game);
|
||||
void runGames(void);
|
||||
void activateGame(e_game nextgame);
|
||||
void disableAllGames(void);
|
||||
|
||||
void initGames(void);
|
||||
void handleGames();
|
||||
|
||||
|
||||
#endif //GAMEH
|
||||
@@ -150,7 +150,7 @@ void handlePowerState(void)
|
||||
{
|
||||
if (!buttonread)
|
||||
{
|
||||
powerstate = on;
|
||||
powerstate = powerinit;
|
||||
powerOn();
|
||||
turnOffAllLed();
|
||||
delay(200);
|
||||
@@ -164,6 +164,12 @@ void handlePowerState(void)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case powerinit:
|
||||
{
|
||||
initGames();
|
||||
powerstate = on;
|
||||
}
|
||||
break;
|
||||
case on:
|
||||
{
|
||||
if (buttonPower.pressedFor(100))
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "led.h"
|
||||
#include "buttons.h"
|
||||
#include "board.h"
|
||||
#include "game.h"
|
||||
|
||||
#ifdef BTN_PWR
|
||||
#include "JC_Button.h"
|
||||
@@ -21,6 +22,7 @@ typedef enum
|
||||
off,
|
||||
poweringOn,
|
||||
poweringOn2,
|
||||
powerinit,
|
||||
on,
|
||||
poweringOff,
|
||||
poweringOff2,
|
||||
|
||||
Reference in New Issue
Block a user