Skip to content

Commit dbbc148

Browse files
committed
Cleaning the code a bit
1 parent e780dea commit dbbc148

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

examples/raspberrypi/rp2xxx/src/ssd1306_oled.zig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,33 @@ const four_rows = empty_row ++ empty_row ++ empty_row ++ empty_row;
3434
pub fn main() void {
3535
var backinf_buffer: [200 * 1024]u8 = undefined;
3636
var fba = std.heap.FixedBufferAllocator.init(&backinf_buffer);
37+
3738
pin_config.apply();
3839
rp2xxx.i2c.I2C.apply(i2c0, .{ .baud_rate = 400_000, .clock_config = rp2xxx.clock_config });
3940

4041
const I2C_DEVICE = rp2xxx.drivers.I2C_Device.init(i2c0, lcd_address, null);
4142
const lcd = microzig.drivers.display.ssd1306.init(.i2c, I2C_DEVICE, null) catch unreachable;
42-
lcd.clear_screen(false) catch unreachable;
43+
4344
const print_val = four_rows ++ " WELCOME!";
4445
var buff: [print_val.len * 8]u8 = undefined;
46+
47+
lcd.clear_screen(false) catch unreachable;
4548
lcd.write_gdram(font8x8.Fonts.draw(&buff, print_val)) catch unreachable;
49+
4650
time.sleep_ms(2000);
4751

4852
var counter: u8 = 0;
4953
while (true) : (time.sleep_ms(1000)) {
50-
lcd.clear_screen(false) catch continue;
5154
var allocator = fba.allocator();
5255
var counter_buf: [80]u8 = undefined;
5356
const text_centered = center(&counter_buf, counter);
57+
5458
const text = font8x8.Fonts.drawAlloc(allocator, text_centered) catch continue;
5559
defer allocator.free(text);
60+
61+
lcd.clear_screen(false) catch continue;
5662
lcd.write_gdram(text) catch continue;
63+
5764
counter += 1;
5865
time.sleep_ms(1000);
5966
if (counter > 59)

0 commit comments

Comments
 (0)