-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinaryLedBackup.txt
More file actions
125 lines (107 loc) · 3.3 KB
/
binaryLedBackup.txt
File metadata and controls
125 lines (107 loc) · 3.3 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "hal_st/instantiations/NucleoTracerInfrastructure.hpp"
#include "hal_st/instantiations/NucleoUi.hpp"
#include "hal_st/instantiations/StmEventInfrastructure.hpp"
#include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp"
#include "hal_st/stm32fxxx/SystemTickStm.cpp"
#include "infra/timer/Timer.hpp"
#include "services/util/DebugLed.hpp"
#include <array>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <string>
using namespace std;
unsigned int hse_value = 8000000;
uint8_t ledCyclus;
string intToByteString(uint8_t& ledCyclus)
{
string byteString = "";
for (int i = 7; i >= 0; i--)
{
int b = ledCyclus >> i;
if (b & 1)
byteString += "1";
else
byteString += "0";
};
return byteString;
}
int main()
{
HAL_Init();
// Configure your clock here
ConfigureDefaultClockNucleo767ZI();
static main_::StmEventInfrastructure eventInfrastructure;
static main_::Nucleo144Ui ui;
// static services::DebugLed debugLed(ui.ledBlue);;
static hal::OutputPin ledRed(ui.ledRed);
static hal::OutputPin ledGreen(ui.ledGreen);
static hal::OutputPin ledBlue(ui.ledBlue);
// static hal::InputPin button(ui.buttonOne);
static main_::NucleoF767ziTracerInfrastructure tracer;
// tracer.tracer.Trace() << str;
static infra::TimerRepeating timer(std::chrono::seconds(1), []()
{
ledCyclus++;
if (ledCyclus == 8)
{
int blinkCounter = 0;
unsigned long currentTime;
unsigned long previousTime;
bool ledsOn = false;
while (true) {
if (blinkCounter >= 10) {
break;
}
currentTime = HAL_GetTick();
if (currentTime - previousTime >= 50) {
blinkCounter++;
if (ledsOn) {
ledRed.Set(false);
ledGreen.Set(false);
ledBlue.Set(false);
ledsOn = false;
} else {
ledRed.Set(true);
ledGreen.Set(true);
ledBlue.Set(true);
ledsOn = true;
}
previousTime = currentTime;
}
}
ledCyclus = 0;
}
string byteString = intToByteString(ledCyclus);
if (byteString.at(5) == '1')
{
ledGreen.Set(true);
}
else
{
ledGreen.Set(false);
};
if (byteString.at(6) == '1')
{
ledBlue.Set(true);
}
else
{
ledBlue.Set(false);
};
if (byteString.at(7) == '1')
{
ledRed.Set(true);
}
else
{
ledRed.Set(false);
};
});
// static hal::InputPin button(ui.buttonOne);
// // tracer.tracer.Trace() << binary ;
// while (true) {
// }
eventInfrastructure.Run();
__builtin_unreachable();
}