Overview
Use i2c init sequence in Arduino Uno, got no logs.
But outed comment,got logs (Both not compilation errors)
Environment of occurrence
- Target:
Arduino Uno
- HAL or MCU:
ATmega328p
- OS/Build Tool:
cargo build & 'serial monitor'
no_std: true
- Feature Flags:
scanner, 'macros'
Reproduction procedure
#![no_std]
#![no_main]
use arduino_hal::prelude::*;
use arduino_hal::i2c;
use dvcdbg::prelude::*;
use sh1107g_rs::{Sh1107gBuilder, DISPLAY_WIDTH, DISPLAY_HEIGHT};
use embedded_graphics::prelude::*;
use embedded_graphics::pixelcolor::BinaryColor;
use panic_halt as _;
use embedded_io::Write;
adapt_serial!(UnoWrapper);
#[arduino_hal::entry]
fn main() -> ! {
let dp = arduino_hal::Peripherals::take().unwrap();
let pins = arduino_hal::pins!(dp);
let mut delay = arduino_hal::Delay::new();
let serial = arduino_hal::default_serial!(dp, pins, 57600);
let mut serial_wrapper = UnoWrapper(serial);
writeln!(serial_wrapper, "[log] Program started.").unwrap();
delay.delay_ms(100u16);
writeln!(serial_wrapper, "[log] Start minimal test").unwrap();
delay.delay_ms(100u16);
let mut i2c = i2c::I2c::new(
dp.TWI,
pins.a4.into_pull_up_input(),
pins.a5.into_pull_up_input(),
100_000,
);
adapt_serial!(I2c);
writeln!(serial_wrapper, "[scan] I2C scan start").unwrap();
dvcdbg::scanner::scan_i2c(&mut i2c, &mut serial_wrapper);
writeln!(serial_wrapper, "[scan] I2C scan done").unwrap();
let mut oled = Sh1107gBuilder::new(i2c)
.clear_on_init(true)
.build();
if oled.init().is_ok() {
writeln!(serial_wrapper, "[oled] init complete").unwrap();
} else {
writeln!(serial_wrapper, "[oled] init failed!").unwrap();
}
oled.clear(BinaryColor::Off).ok();
oled.flush().ok();
writeln!(serial_wrapper, "[oled] cleared (black)").unwrap();
for x in 0..DISPLAY_WIDTH {
let _ = oled.draw_iter([Pixel(Point::new(x as i32, (DISPLAY_HEIGHT/2) as i32), BinaryColor::On)]);
}
for y in 0..DISPLAY_HEIGHT {
let _ = oled.draw_iter([Pixel(Point::new((DISPLAY_WIDTH/2) as i32, y as i32), BinaryColor::On)]);
}
oled.flush().ok();
writeln!(serial_wrapper, "[oled] cross line drawn").unwrap();
loop {
delay.delay_ms(1000u16);
}
}
Expected behaviour
Got writeln logs
Actual behaviour
No logs but outed comment i2c init sequence, got writeln log (one line)
Supplementary information
Need to identify where in your wrapper you are squashing errors and fix the errors that slip through the anomaly.
Overview
Use i2c init sequence in Arduino Uno, got no logs.
But outed comment,got logs (Both not compilation errors)
Environment of occurrence
Arduino UnoATmega328pcargo build& 'serial monitor'no_std: truescanner, 'macros'Reproduction procedure
Expected behaviour
Got writeln logs
Actual behaviour
No logs but outed comment i2c init sequence, got writeln log (one line)
Supplementary information
Need to identify where in your wrapper you are squashing errors and fix the errors that slip through the anomaly.