Skip to content

Commit 80ba0cc

Browse files
authored
Merge pull request #11 from jamisonderek/jamisonderek/signed-col
simplify column data
2 parents 660f244 + 939f9d0 commit 80ba0cc

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

401lightMessengerApp/401LightMsg_acc.c

+8-18
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ static int32_t app_acc_worker(void* ctx) {
191191
bool is_bitmap_window = 0; // Check if
192192
// FuriMutex *mutex = appAcc->mutex;
193193

194-
uint8_t column = 0; // Column of the bitmap array
195-
uint8_t column_directed = 0; // Column of the bitmap array
194+
int16_t column = 0; // Column of the bitmap array
195+
int16_t column_directed = 0; // Column of the bitmap array
196196

197197
uint8_t row = 0;
198198

@@ -293,30 +293,20 @@ static int32_t app_acc_worker(void* ctx) {
293293
// Get current column to be displayed.
294294
column = appAcc->cycles - ((appAcc->cyclesCenter) - (bitmapMatrix->width / 2));
295295

296+
// Computes the window in which the text is displayed.
297+
is_bitmap_window = (column >= 0) && (column < bitmapMatrix->width);
298+
296299
// Swipe direction, according to orientation
297-
if(appAcc->direction ^ light_msg_data->orientation) {
298-
column_directed = (column % bitmapMatrix->width) - appAcc->direction;
300+
if(appAcc->direction ^ light_msg_data->orientation ^ light_msg_data->mirror) {
301+
column_directed = column;
299302
} else {
300-
column_directed =
301-
bitmapMatrix->width - (column % (bitmapMatrix->width)) - appAcc->direction;
303+
column_directed = bitmapMatrix->width - column - 1;
302304
}
303305

304-
// Computes the window in which the text is displayed.
305-
// low limit = center - len / 2
306-
// high limit = center + len / 2
307-
is_bitmap_window =
308-
(appAcc->cycles >
309-
(appAcc->cyclesCenter - ((bitmapMatrix->width - appAcc->direction) / 2))) &&
310-
(appAcc->cycles <=
311-
(appAcc->cyclesCenter + ((bitmapMatrix->width - appAcc->direction) / 2)));
312-
313306
// Update the color according to the current shader
314307
shader(time, appAcc->direction ^ light_msg_data->orientation, color, app);
315308

316309
if(is_bitmap_window) {
317-
if(light_msg_data->mirror) {
318-
column_directed = bitmapMatrix->width - column_directed;
319-
}
320310
// Draws each rows for each collumns
321311
for(row = 0; row < LIGHTMSG_LED_ROWS; row++) {
322312
pixel = (uint8_t)(bitmapMatrix->array[row][column_directed]);

0 commit comments

Comments
 (0)