fix bitmap drawing, align number picker screen to center
This commit is contained in:
@@ -324,13 +324,13 @@ void LCD_setBitmapFullScreen(const uint8_t *bitArray)
|
||||
|
||||
void LCD_setBitmap(const struct BitmapImage *image, int x, int y, bool bg, enum Color color)
|
||||
{
|
||||
int byte_count = image->width * (image->height + 7) / 8;
|
||||
// int byte_count = image->width * ((image->height + 7) / 8);
|
||||
|
||||
for (int xi = 0; xi < image->width; xi++) {
|
||||
for (int yi = 0; yi < image->height; yi++) {
|
||||
int idx = xi + ((yi + 7) / 8) * image->width;
|
||||
if (idx > byte_count) continue;
|
||||
bool bit = image->bytes[idx] & (1 << yi);
|
||||
int idx = xi + (yi / 8) * image->width;
|
||||
// if (idx > byte_count) continue;
|
||||
bool bit = image->bytes[idx] & (1 << (yi % 8));
|
||||
if (bit) {
|
||||
LCD_setPixel(x + xi, y + yi, color);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include "scenes.h"
|
||||
|
||||
#include "liquid.h"
|
||||
#include "graphics/drawing.h"
|
||||
#include "scene_number.h"
|
||||
#include "graphics/display_spec.h"
|
||||
|
||||
struct NumberScene {
|
||||
struct Scene base;
|
||||
@@ -40,11 +41,11 @@ static void paint(struct NumberScene *self)
|
||||
struct NumberSceneOpts *opts = self->opts;
|
||||
|
||||
LCD_clearDisplay(0);
|
||||
LCD_setStrEx(opts->label, 1, 1, BLACK, (struct TextStyle) {.size = FONT_BOLD});
|
||||
LCD_setStrEx(opts->label, LCD_WIDTH/2, 1, BLACK, (struct TextStyle) {.size = FONT_BOLD, .align=ALIGN_CENTER});
|
||||
|
||||
char buf[10];
|
||||
snprintf(buf, 10, "%d%s", opts->value, opts->unit);
|
||||
LCD_setStrEx(buf, 1, 9, BLACK, (struct TextStyle) {.size = FONT_DOUBLE});
|
||||
LCD_setStrEx(buf, LCD_WIDTH/2, 14, BLACK, (struct TextStyle) {.size = FONT_DOUBLE, .align=ALIGN_CENTER});
|
||||
}
|
||||
|
||||
static void deinit(struct NumberScene *self)
|
||||
|
||||
Reference in New Issue
Block a user