This repository has been archived by the owner on Sep 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: this was able to sign a transaction on-chain (#60)
* feat: this was able to sign a transaction on-chain * refactor: cleanup * feat: make red light shine
- Loading branch information
Showing
12 changed files
with
120 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use embedded_graphics::{ | ||
mono_font::{ | ||
ascii::{FONT_6X10}, | ||
MonoTextStyle, | ||
}, | ||
Pixel, | ||
primitives::Rectangle, | ||
Drawable, | ||
}; | ||
use embedded_graphics_core::{ | ||
draw_target::DrawTarget, | ||
geometry::{Point, Size}, | ||
pixelcolor::BinaryColor, | ||
}; | ||
use embedded_text::{ | ||
alignment::{HorizontalAlignment, VerticalAlignment}, | ||
style::{HeightMode, TextBoxStyleBuilder}, | ||
TextBox, | ||
}; | ||
|
||
use crate::display_def::*; | ||
use qrcodegen_noheap::{QrCode, QrCodeEcc, Version}; | ||
|
||
pub fn draw<D>(data_to_qr: &[u8], display: &mut D) -> Result<(), D::Error> | ||
where | ||
D: DrawTarget<Color = BinaryColor>, | ||
{ | ||
let len = data_to_qr.len(); | ||
|
||
let mut outbuffer = [0u8; Version::new(18).buffer_len()].to_vec(); | ||
let mut dataandtemp = [0u8; Version::new(18).buffer_len()].to_vec(); | ||
|
||
dataandtemp[..len].copy_from_slice(data_to_qr); | ||
|
||
let qr_code = QrCode::encode_binary(&mut dataandtemp, len, &mut outbuffer, QrCodeEcc::Low, Version::MIN, Version::new(18), None, true).unwrap(); | ||
|
||
let scaling = { | ||
if qr_code.version() == Version::new(18) {2} | ||
else {SCREEN_SIZE_Y as i32/qr_code.size()} | ||
}; | ||
|
||
let size = qr_code.size() * scaling; | ||
for y in 0..size { | ||
for x in 0..size { | ||
let color = { | ||
if qr_code.get_module(x / scaling, y / scaling) {BinaryColor::On} | ||
else {BinaryColor::Off} | ||
}; | ||
let x_point = SCREEN_SIZE_X as i32/2 - size/2 + x; | ||
let y_point = SCREEN_SIZE_Y as i32/2 - size/2 + y; | ||
let point = Point::new(x_point, y_point); | ||
let pixel = Pixel::<BinaryColor>(point, color); | ||
pixel.draw(display)?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters