[2025-05-12] Syntax highlighting through CSS and markdown
This commit is contained in:
parent
fafa5ee954
commit
9f630196ed
6 changed files with 98 additions and 22 deletions
|
@ -35,7 +35,7 @@ But where is the fun in that?! Something about this project wouldn't let me just
|
|||
|
||||
I started out by trying to just send commands to the screen. I knew the default address of the device from the datasheet (0x3C), and started firing commands over I2C to try and provoke any sort of reaction. The MicroZig driver allowed me to this super easily. Just setup the I2C device, and then send data using the `write_blocking` function. I put the sending code inside a little function to make things easier to parse:
|
||||
|
||||
```
|
||||
```zig
|
||||
const i2c0 = i2c.num(0);
|
||||
_ = i2c0.apply(.{
|
||||
.clock_config = rp2040.clock_config,
|
||||
|
@ -44,7 +44,7 @@ _ = i2c0.apply(.{
|
|||
.baud_rate = 400000,
|
||||
});
|
||||
```
|
||||
```
|
||||
```zig
|
||||
pub fn send(bytes: []const u8) !void {
|
||||
const a: i2c.Address = @enumFromInt(0x3C);
|
||||
_ = i2c0.write_blocking(a, bytes) catch {
|
||||
|
@ -57,7 +57,7 @@ The SSD1306, stood firm, resolutely denying me even a single pixel. There is no
|
|||
|
||||
It was at this point that I became really impressed with Zig's compilation, and in particular the caching. As part of this process, I was messing around a lot with my code, and then building and loading onto the Pico with the following command:
|
||||
|
||||
```
|
||||
```bash
|
||||
zig build; picotool load -x zig-out/firmware/pico_i2c.uf2
|
||||
```
|
||||
|
||||
|
@ -83,7 +83,7 @@ Surely I was almost there? Well, almost yes, but not quite. Matiasus's commands
|
|||
|
||||
The thing that made the breakthrough for me was [this holy grail of a blog post](https://nnarain.github.io/2020/12/01/SSD1306-OLED-Display-Driver-using-I2C.html). Just exactly what I needed at exactly the right time. It calmly and thoroughly explains the process of communicating with the display, as well as the initialisation. I was mostly right in what I interpreted from the datasheet, but it is always nice to have things confirmed by someone who clearly understands this better than you. This led me to the following initialisation commands:
|
||||
|
||||
```
|
||||
```zig
|
||||
const INIT = [_]u8{
|
||||
CONTROL_COMMAND, 0xAE,
|
||||
CONTROL_COMMAND, 0xA8, 0x1F,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue