MCPcopy Create free account
hub / github.com/cifertech/nRFBox / outputChannels

Function outputChannels

nRFBox_V2/scanner.cpp:97–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96
97void outputChannels(void) {
98 int norm = 0;
99
100 // Find the maximum value in the channel array for normalization
101 for (int i = 0; i < CHANNELS; i++) {
102 if (channel[i] > norm) {
103 norm = channel[i];
104 }
105 }
106
107 byte drawHeight = map(norm, 0, 64, 0, 64);
108
109 // Update sensorArray with the new value (shift left for right-to-left movement)
110 for (byte count = 126; count > 0; count--) {
111 sensorArray[count] = sensorArray[count - 1];
112 }
113 sensorArray[0] = drawHeight;
114
115 u8g2.clearBuffer();
116
117 u8g2.drawLine(0, 0, 0, 63);
118 u8g2.drawLine(127, 0, 127, 63);
119
120 for (byte count = 0; count < 64; count += 10) {
121 u8g2.drawLine(127, count, 122, count); // Right side markers
122 u8g2.drawLine(0, count, 5, count); // Left side markers
123 }
124
125 for (byte count = 10; count < 127; count += 10) {
126 u8g2.drawPixel(count, 0);
127 u8g2.drawPixel(count, 63);
128 }
129
130 // Draw the graph moving right-to-left
131 for (byte count = 0; count < 127; count++) {
132 u8g2.drawLine(127 - count, 63, 127 - count, 63 - sensorArray[count]);
133 setNeoPixelColour("purple");
134 }
135
136 setNeoPixelColour("0");
137
138 u8g2.setFont(u8g2_font_ncenB08_tr);
139 u8g2.setCursor(12, 12);
140 u8g2.print("[");
141 u8g2.print(norm);
142 u8g2.print("]");
143
144 u8g2.sendBuffer();
145}
146
147void loadPreviousGraph() {
148 EEPROM.begin(128);

Callers 1

scannerLoopFunction · 0.70

Calls 1

setNeoPixelColourFunction · 0.85

Tested by

no test coverage detected