Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with 128x32 Display on Elegoo Arduino UnoR3 #190

Open
avlec opened this issue Aug 5, 2023 · 0 comments
Open

Issues with 128x32 Display on Elegoo Arduino UnoR3 #190

avlec opened this issue Aug 5, 2023 · 0 comments

Comments

@avlec
Copy link

avlec commented Aug 5, 2023

  • Version of ssd1306 in use (if applicable): 0.8.0
  • MCU/other hardware in use: Elegoo Arduino Uno R3
  • Display resolution and interface: I2C 128x32

Description of the problem/feature request/other

Display seems to not be writable to with any data. Have yet to try with out the use of terminal or buffered modes. Those modes seem to cause the device to do very strange things. Sometimes causing a lot of repeated data to be blasted out the serial port.

Test case (if applicable)

[package]
name = "bikelo"
version = "0.1.0"
authors = ["avlec"]
edition = "2021"
license = "MIT OR Apache-2.0"

[[bin]]
name = "bikelo"
test = false
bench = false

[dependencies]
ufmt = "0.1.0"
nb = "0.1.2"
embedded-hal = "0.2.3"
ssd1306="0.8.0"
embedded-graphics="0.8.0"

[dependencies.arduino-hal]
git = "https://github.com/rahix/avr-hal"
rev = "7dfa6d322b9df98b2d98afe0e14a97afe0187ac1"
features = ["arduino-uno"]

# Configure the build for minimal size - AVRs have very little program memory
[profile.dev]
codegen-units = 1
panic = "abort"
lto = true
opt-level = "s"

[profile.release]
panic = "abort"
codegen-units = 1
debug = true
lto = true
opt-level = "s"
#![no_std]
#![no_main]

use embedded_graphics::{
    mono_font::{ascii::FONT_6X10, MonoTextStyleBuilder},
    pixelcolor::BinaryColor,
    prelude::*,
    text::{Baseline, Text},
};
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};

#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
    let dp = unsafe { arduino_hal::Peripherals::steal() };
    let pins = arduino_hal::pins!(dp);
    let mut serial = arduino_hal::default_serial!(dp, pins, 57600);

    ufmt::uwriteln!(&mut serial, "Firmware panic!\r").unwrap();
    if let Some(loc) = info.location() {
        ufmt::uwriteln!(
            &mut serial,
            "  At {}:{}:{}\r",
            loc.file(),
            loc.line(),
            loc.column(),
        )
        .unwrap();
    }

    let mut led = pins.d13.into_output();
    loop {
        led.toggle();
        arduino_hal::delay_ms(500);
    }
}

#[arduino_hal::entry]
fn main() -> ! {
    /*   let dp = arduino_hal::Peripherals::take().unwrap();
    let pins = arduino_hal::pins!(dp);
    let mut serial = arduino_hal::default_serial!(dp, pins, 57600);

    ufmt::uwriteln!(&mut serial, "Things should be working...\r").unwrap();

    arduino_hal::delay_ms(500);
    panic!();
    loop {}*/
    let dp = arduino_hal::Peripherals::take().unwrap();
    let pins = arduino_hal::pins!(dp);
    let mut serial = arduino_hal::default_serial!(dp, pins, 57600);

    ufmt::uwriteln!(&mut serial, "try i2c.\r").unwrap();

    let mut led = pins.d13.into_output();

    let mut i2c = arduino_hal::I2c::new(
        dp.TWI,
        pins.a4.into_pull_up_input(),
        pins.a5.into_pull_up_input(),
        50000,
    );

    ufmt::uwriteln!(&mut serial, "Initialized components.\r").unwrap();

    let interface = I2CDisplayInterface::new(i2c);
    let mut display = Ssd1306::new(interface, DisplaySize128x32, DisplayRotation::Rotate0)
        .into_buffered_graphics_mode();

    display.init().unwrap();

    ufmt::uwriteln!(&mut serial, "Initialized display.\r").unwrap();

    let style = MonoTextStyleBuilder::new()
        .font(&FONT_6X10)
        .text_color(BinaryColor::On)
        .build();

    Text::with_baseline("Help", Point::new(1, 1), style, Baseline::Top)
        .draw(&mut display)
        .unwrap();

    display.flush().unwrap();

    loop {}
}
@avlec avlec changed the title y Issues with 128x32 Display on Arduino UnoR3 Aug 5, 2023
@avlec avlec changed the title Issues with 128x32 Display on Arduino UnoR3 Issues with 128x32 Display on Arduino UnoR3 (Elegoo model) Aug 5, 2023
@avlec avlec changed the title Issues with 128x32 Display on Arduino UnoR3 (Elegoo model) Issues with 128x32 Display on Elegoo Arduino UnoR3 Aug 5, 2023
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

No branches or pull requests

1 participant