Skip to content

Conversation

@Gnyblast
Copy link
Contributor

No description provided.

@Gnyblast Gnyblast changed the title rp2xxxx: ssd1306 oled display example rp2xxx: ssd1306 oled display example Aug 14, 2025
Copy link
Contributor

@mattnite mattnite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important that examples are compiled so that CI catches breaks. It's okay to add a dependency to the example as it is separate from the actual package. I also see that it is your package, and that is fine, but it needs to have a compatible LICENSE, and the dependency must link to a commit with that license. If you fail to maintain that package in the future and it blocks our CI, this example can be removed.

@tact1m4n3
Copy link
Collaborator

You should also add the example to build.zig as well adding the module import. These are the changes you need to make:

diff --git a/examples/raspberrypi/rp2xxx/build.zig b/examples/raspberrypi/rp2xxx/build.zig
index 1add360d..8a4382ed 100644
--- a/examples/raspberrypi/rp2xxx/build.zig
+++ b/examples/raspberrypi/rp2xxx/build.zig
@@ -9,6 +9,8 @@ pub fn build(b: *std.Build) void {
     const optimize = b.standardOptimizeOption(.{});
     const maybe_example = b.option([]const u8, "example", "only build matching examples");
 
+    const font8x8_dep = b.dependency("font8x8", .{});
+
     const mz_dep = b.dependency("microzig", .{});
     const mb = MicroBuild.init(b, mz_dep) orelse return;
 
@@ -68,6 +70,9 @@ pub fn build(b: *std.Build) void {
         .{ .name = "dma", .file = "src/dma.zig" },
         .{ .name = "cyw43", .file = "src/cyw43.zig" },
         .{ .name = "mlx90640", .file = "src/mlx90640.zig" },
+        .{ .name = "ssd1306-oled", .file = "src/ssd1306_oled.zig", .imports = &.{
+            .{ .name = "font8x8", .module = font8x8_dep.module("font8x8") },
+        } },
     };
 
     var available_examples = std.ArrayList(Example).init(b.allocator);
@@ -77,12 +82,14 @@ pub fn build(b: *std.Build) void {
             .target = mb.ports.rp2xxx.boards.raspberrypi.pico,
             .name = b.fmt("pico_{s}", .{example.name}),
             .file = example.file,
+            .imports = example.imports,
         }) catch @panic("out of memory");
 
         available_examples.append(.{
             .target = mb.ports.rp2xxx.boards.raspberrypi.pico2_arm,
             .name = b.fmt("pico2_arm_{s}", .{example.name}),
             .file = example.file,
+            .imports = example.imports,
         }) catch @panic("out of memory");
 
         if (example.works_with_riscv) {
@@ -90,6 +97,7 @@ pub fn build(b: *std.Build) void {
                 .target = mb.ports.rp2xxx.boards.raspberrypi.pico2_riscv,
                 .name = b.fmt("pico2_riscv_{s}", .{example.name}),
                 .file = example.file,
+                .imports = example.imports,
             }) catch @panic("out of memory");
         }
     }
@@ -110,6 +118,7 @@ pub fn build(b: *std.Build) void {
             .target = example.target,
             .optimize = optimize,
             .root_source_file = b.path(example.file),
+            .imports = example.imports,
         });
 
         // `install_firmware()` is the MicroZig pendant to `Build.installArtifact()`
@@ -127,10 +136,12 @@ const Example = struct {
     target: *const microzig.Target,
     name: []const u8,
     file: []const u8,
+    imports: []const std.Build.Module.Import = &.{},
 };
 
 const ChipAgnosticExample = struct {
     name: []const u8,
     file: []const u8,
     works_with_riscv: bool = true,
+    imports: []const std.Build.Module.Import = &.{},
 };

To test that your example is building you should run zig build -Dexample=ssd1306-oled in the rp2xxx examples directory and check the zig-out directory.

@Gnyblast
Copy link
Contributor Author

Gnyblast commented Nov 1, 2025

I made the most changes but I was having some errors and couldn't find time since then to look into it. Maybe this week I can have sometime to look.
Thanks.

@Gnyblast Gnyblast requested a review from Grazfather November 22, 2025 12:44
@Gnyblast Gnyblast requested a review from Grazfather November 22, 2025 16:47
@Grazfather
Copy link
Collaborator

Were you able to test this after your changes? Looks good to me. Thanks for your patience with my review!

@Gnyblast
Copy link
Contributor Author

Were you able to test this after your changes? Looks good to me. Thanks for your patience with my review!

No worries, all required...

Yeah I tested it on every bit of changes we were doing. Just one thing; on my RP2040 it worked with pins 8 and 9 not 4 and 5 but I guess there might be a problem with mine specific MCU:

ssd1306

@Grazfather
Copy link
Collaborator

It should work on either, but maybe you wired it wrong. Thanks for testing it.

@Grazfather Grazfather merged commit 2f6b697 into ZigEmbeddedGroup:main Nov 22, 2025
47 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants