Skip to content

Commit 3a13171

Browse files
authored
Cleanup (awawa-dev#3)
1 parent a9ebd99 commit 3a13171

File tree

7 files changed

+51
-57
lines changed

7 files changed

+51
-57
lines changed

.github/workflows/push-master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
release: '12.2.Rel1'
2323

24-
- name: Build packages
24+
- name: Build packages
2525
shell: bash
2626
run: |
2727
mkdir build
@@ -54,7 +54,7 @@ jobs:
5454
needs: [HyperSerialPico]
5555
runs-on: ubuntu-latest
5656
permissions:
57-
contents: write
57+
contents: write
5858
steps:
5959
# generate environment variables
6060
- name: Generate environment variables from version and tag

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ set(CMAKE_CXX_STANDARD 17)
3434

3535
IF(CMAKE_COMPILER_IS_GNUCC)
3636
string(REGEX REPLACE "(\-O[011123456789])" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
37-
string(REGEX REPLACE "(\-O[011123456789])" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
37+
string(REGEX REPLACE "(\-O[011123456789])" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
3838
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Og")
3939
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Og")
4040
ENDIF(CMAKE_COMPILER_IS_GNUCC)
@@ -47,15 +47,15 @@ set(HyperSerialPicoCompanionLibs FreeRTOS-Kernel FreeRTOS-Kernel-Heap1 pico_stdl
4747
set(HyperSerialPicoCompanionIncludes ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sdk/config)
4848
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/generated)
4949
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/firmwares)
50-
50+
5151
macro(HyperSerialPicoTarget HyperSerialPicoTargetName)
5252
add_executable(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/source/main.cpp)
5353
target_include_directories(${HyperSerialPicoTargetName} PRIVATE ${HyperSerialPicoCompanionIncludes})
5454
target_link_libraries(${HyperSerialPicoTargetName} ${HyperSerialPicoCompanionLibs})
5555
pico_add_extra_outputs(${HyperSerialPicoTargetName})
5656
pico_enable_stdio_usb(${HyperSerialPicoTargetName} 1)
5757
pico_enable_stdio_uart(${HyperSerialPicoTargetName} 0)
58-
pico_generate_pio_header(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/pio/neopixel.pio OUTPUT_DIR ${CMAKE_SOURCE_DIR}/generated)
58+
pico_generate_pio_header(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/pio/neopixel.pio OUTPUT_DIR ${CMAKE_SOURCE_DIR}/generated)
5959
add_custom_command(TARGET ${HyperSerialPicoTargetName} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/${HyperSerialPicoTargetName}.uf2 ${CMAKE_SOURCE_DIR}/firmwares)
6060
endmacro()
6161

@@ -84,5 +84,5 @@ ELSE()
8484
target_compile_definitions("HyperSerialPico_sk6812Neutral_rev_multisegment_at_${SECOND_SEGMENT_INDEX}" PRIVATE -DNEOPIXEL_RGBW -DDATA_PIN=${OUTPUT_DATA_PIN} -DSECOND_SEGMENT_START_INDEX=${SECOND_SEGMENT_INDEX} -DSECOND_SEGMENT_REVERSED)
8585
HyperSerialPicoTarget("HyperSerialPico_ws2812_rev_multisegment_at_${SECOND_SEGMENT_INDEX}")
8686
target_compile_definitions("HyperSerialPico_ws2812_rev_multisegment_at_${SECOND_SEGMENT_INDEX}" PRIVATE -DNEOPIXEL_RGB -DDATA_PIN=${OUTPUT_DATA_PIN} -DSECOND_SEGMENT_START_INDEX=${SECOND_SEGMENT_INDEX} -DSECOND_SEGMENT_REVERSED)
87-
ENDIF()
87+
ENDIF()
8888
ENDIF()

include/calibration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,5 @@ class CalibrationConfig
130130
printf(output);
131131
}
132132
} calibrationConfig;
133-
#endif
134133

134+
#endif

include/leds.h

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct ColorGrb
103103
uint8_t B;
104104
uint8_t R;
105105
uint8_t G;
106-
106+
107107

108108
ColorGrb(uint8_t gray) :
109109
R(gray), G(gray), B(gray)
@@ -116,7 +116,7 @@ struct ColorGrb
116116
};
117117

118118
struct ColorGrbw
119-
{
119+
{
120120
uint8_t W;
121121
uint8_t B;
122122
uint8_t R;
@@ -134,13 +134,13 @@ struct ColorGrbw
134134
static bool isAlignedTo24()
135135
{
136136
return false;
137-
};
137+
};
138138
};
139139

140140
struct ColorDotstartBgr
141-
{
141+
{
142142
uint8_t brightness;
143-
uint8_t B;
143+
uint8_t B;
144144
uint8_t G;
145145
uint8_t R;
146146

@@ -155,16 +155,16 @@ struct ColorDotstartBgr
155155
};
156156

157157
class LedDriver
158-
{
158+
{
159159
protected:
160160

161161
int ledsNumber;
162162
int pin;
163163
int clockPin;
164164
int dmaSize;
165165
uint8_t* buffer;
166-
uint8_t* dma;
167-
166+
uint8_t* dma;
167+
168168
public:
169169

170170
LedDriver(int _ledsNumber, int _pin, int _dmaSize): LedDriver(_ledsNumber, _pin, 0, _dmaSize)
@@ -191,7 +191,7 @@ class LedDriver
191191
free(dma);
192192
if (LedDriverDmaReceiver == this)
193193
LedDriverDmaReceiver = nullptr;
194-
}
194+
}
195195

196196
static LedDriver* LedDriverDmaReceiver;
197197
};
@@ -213,21 +213,21 @@ class DmaClient
213213
DmaClient()
214214
{
215215
PICO_DMA_CHANNEL = dma_claim_unused_channel(true);
216-
isDmaBusy = false;
216+
isDmaBusy = false;
217217
lastRenderTime = 0;
218218
};
219219

220220
~DmaClient()
221221
{
222222
for(int i = 0; i < 10 && isDmaBusy; i++)
223-
busy_wait_us(500);
223+
busy_wait_us(500);
224224

225225
dma_channel_abort(PICO_DMA_CHANNEL);
226226
dma_channel_set_irq0_enabled(PICO_DMA_CHANNEL, false);
227227
irq_set_enabled(DMA_IRQ_0, false);
228228

229229
dma_channel_unclaim(PICO_DMA_CHANNEL);
230-
};
230+
};
231231

232232
void dmaConfigure(PIO _selectedPIO, uint _sm)
233233
{
@@ -270,9 +270,9 @@ class DmaClient
270270
int wait = 200;
271271
while(isDmaBusy && wait-- > 0)
272272
busy_wait_us(50);
273-
273+
274274
return !isDmaBusy;
275-
}
275+
}
276276

277277
bool isReady()
278278
{
@@ -284,15 +284,15 @@ class DmaClient
284284
if (dma_hw->ints0 & (1u<<DmaClient::PICO_DMA_CHANNEL))
285285
{
286286
dma_hw->ints0 = (1u<<DmaClient::PICO_DMA_CHANNEL);
287-
287+
288288
lastRenderTime = time_us_64();
289289
isDmaBusy = false;
290290
}
291291
}
292292
};
293293

294294
class Neopixel : public LedDriver, public DmaClient
295-
{
295+
{
296296

297297
uint64_t resetTime;
298298

@@ -329,12 +329,12 @@ class Neopixel : public LedDriver, public DmaClient
329329
pio_sm_set_consecutive_pindirs(selectedPIO, stateIndex, _pin, std::max(lanes, 1), true);
330330
sm_config_set_out_shift(&smConfig, false, true, (alignTo24) ? 24: 32);
331331
sm_config_set_fifo_join(&smConfig, PIO_FIFO_JOIN_TX);
332-
float div = clock_get_hz(clk_sys) / (800000 * 12);
332+
float div = clock_get_hz(clk_sys) / (800000 * 12);
333333
sm_config_set_clkdiv(&smConfig, div);
334334
pio_sm_init(selectedPIO, stateIndex, programAddress, &smConfig);
335335
pio_sm_set_enabled(selectedPIO, stateIndex, true);
336336

337-
initDmaPio(dmaSize / 4);
337+
initDmaPio(dmaSize / 4);
338338
}
339339

340340
uint8_t* getBufferMemory()
@@ -355,29 +355,29 @@ class Neopixel : public LedDriver, public DmaClient
355355
if (currentTime < resetTime + lastRenderTime)
356356
busy_wait_us(std::min(resetTime + lastRenderTime - currentTime, resetTime));
357357

358-
memcpy(dma, buffer, dmaSize);
358+
memcpy(dma, buffer, dmaSize);
359359

360360
dma_channel_set_read_addr(PICO_DMA_CHANNEL, dma, true);
361361

362362
if (resetBuffer)
363363
memset(buffer, 0, dmaSize);
364-
}
364+
}
365365
};
366366

367367
template<int RESET_TIME, typename colorData>
368368
class NeopixelType : public Neopixel
369-
{
369+
{
370370
public:
371371

372372
NeopixelType(int _ledsNumber, int _pin) : Neopixel(0, RESET_TIME, _ledsNumber, _pin, _ledsNumber * sizeof(colorData), colorData::isAlignedTo24())
373373
{
374374
}
375-
375+
376376
void SetPixel(int index, colorData color)
377377
{
378378
if (index >= ledsNumber)
379379
return;
380-
380+
381381
*(reinterpret_cast<colorData*>(buffer)+index) = color;
382382
}
383383

@@ -395,7 +395,7 @@ class NeopixelParallel
395395

396396
protected:
397397
static int maxLeds;
398-
const uint8_t myLaneMask;
398+
const uint8_t myLaneMask;
399399
static uint8_t* buffer;
400400

401401
public:
@@ -432,26 +432,26 @@ class NeopixelParallel
432432
bool isReady()
433433
{
434434
return muxer->isReady();
435-
}
435+
}
436436

437437
void renderAllLanes()
438438
{
439439
muxer->renderDma(true);
440-
}
440+
}
441441
};
442442

443443
template<int RESET_TIME, typename colorData>
444444
class NeopixelParallelType : public NeopixelParallel
445445
{
446446
uint32_t lut[16];
447447

448-
public:
448+
public:
449449

450450
NeopixelParallelType(int _ledsNumber, int _basePinForLanes) : NeopixelParallel(sizeof(colorData), RESET_TIME,
451451
_ledsNumber, _basePinForLanes)
452452
{
453453
for (uint8_t a = 0; a < 16; a++)
454-
{
454+
{
455455
uint8_t* target = reinterpret_cast<uint8_t*>(&(lut[a]));
456456
for (uint8_t b = 0; b < 4; b++)
457457
*(target++) = (uint8_t) ((a & (0b00000001 << b)) ? myLaneMask : 0);
@@ -462,16 +462,16 @@ class NeopixelParallelType : public NeopixelParallel
462462
{
463463
if (index >= maxLeds)
464464
return;
465-
465+
466466
uint8_t* source = reinterpret_cast<uint8_t*>(&color);
467467
uint32_t* target = reinterpret_cast<uint32_t*>(&(buffer[(index + 1) * 8 * sizeof(colorData)]));
468468

469469
for(int i = 0; i < sizeof(colorData); i++)
470-
{
471-
*(--target) |= lut[ *(source) & 0b00001111];
470+
{
471+
*(--target) |= lut[ *(source) & 0b00001111];
472472
*(--target) |= lut[ *(source++) >> 4];
473473
}
474-
}
474+
}
475475
};
476476

477477
class Dotstar : public LedDriver, public DmaClient
@@ -485,7 +485,7 @@ class Dotstar : public LedDriver, public DmaClient
485485
LedDriver(_ledsNumber, _datapin, _clockpin, _dmaSize)
486486
{
487487
dmaConfigure(pio0, 0);
488-
resetTime = _resetTime;
488+
resetTime = _resetTime;
489489

490490
spi_init(spi_default, 10000000);
491491
gpio_set_function(PICO_DEFAULT_SPI_RX_PIN, GPIO_FUNC_SPI);
@@ -496,7 +496,7 @@ class Dotstar : public LedDriver, public DmaClient
496496
bi_decl(bi_1pin_with_name(PICO_DEFAULT_SPI_CSN_PIN, "SPI CS"));
497497

498498
initDmaSpi(_dmaSize);
499-
}
499+
}
500500

501501
uint8_t* getBufferMemory()
502502
{
@@ -544,7 +544,7 @@ class DotstarType : public Dotstar
544544
memset(buffer,0 ,4);
545545
*(reinterpret_cast<colorData*>(buffer)+ledsNumber+1) = colorData(0xff);
546546
renderDma();
547-
}
547+
}
548548
};
549549

550550
Neopixel* NeopixelParallel::muxer = nullptr;
@@ -562,4 +562,3 @@ typedef NeopixelType<450, ColorGrbw> sk6812;
562562
typedef NeopixelParallelType<300, ColorGrb> ws2812p;
563563
typedef NeopixelParallelType<80, ColorGrbw> sk6812p;
564564
typedef DotstarType<100, ColorDotstartBgr> apa102;
565-

pio/neopixel.pio

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
; SOFTWARE.
24-
24+
2525

2626
.program neopixel
2727
.side_set 1

sdk/config/FreeRTOSConfig.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,3 @@ to exclude the API function. */
136136
/* A header file that defines trace macro can be included here. */
137137

138138
#endif /* FREERTOS_CONFIG_H */
139-

source/main.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
#pragma message(VAR_NAME_VALUE(CLOCK_PIN))
8080
#endif
8181

82-
#if defined(SECOND_SEGMENT_START_INDEX)
82+
#if defined(SECOND_SEGMENT_START_INDEX)
8383
#pragma message("Using parallel mode for segments")
8484

8585
#ifdef NEOPIXEL_RGBW
@@ -93,7 +93,7 @@
9393
#else
9494
#error "Parallel mode is unsupportd for selected LEDs configuration"
9595
#endif
96-
96+
9797
#pragma message(VAR_NAME_VALUE(LED_DRIVER))
9898
#pragma message(VAR_NAME_VALUE(SECOND_SEGMENT_START_INDEX))
9999
#pragma message(VAR_NAME_VALUE(LED_DRIVER2))
@@ -117,7 +117,7 @@ static void core1()
117117
{
118118
if (sem_acquire_timeout_us(&base.serialSemaphore, portMAX_DELAY))
119119
{
120-
processData();
120+
processData();
121121
}
122122
}
123123
}
@@ -145,14 +145,14 @@ static void core0( void *pvParameters )
145145
}
146146

147147
static void serialEvent(void *)
148-
{
149-
sem_release(&base.receiverSemaphore);
148+
{
149+
sem_release(&base.receiverSemaphore);
150150
}
151151

152152
int main(void)
153153
{
154154
stdio_init_all();
155-
155+
156156
sem_init(&base.serialSemaphore, 0, 1);
157157

158158
sem_init(&base.receiverSemaphore, 0, 1);
@@ -167,11 +167,7 @@ int main(void)
167167
NULL,
168168
(configMAX_PRIORITIES - 1),
169169
&base.processSerialHandle);
170-
171-
vTaskStartScheduler();
170+
171+
vTaskStartScheduler();
172172
panic_unsupported();
173173
}
174-
175-
176-
177-

0 commit comments

Comments
 (0)