Skip to content

Added support for inverting single bit signals #97

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,12 @@ fn signal_from_payload(mut w: impl Write, signal: &Signal, msg: &Message) -> Res
writeln!(&mut w)?;

if signal.signal_size == 1 {
writeln!(&mut w, "signal == 1")?;
// inverted bit signal
if signal.factor == -1.0 && signal.offset == 1.0 {
writeln!(&mut w, "signal == 0")?;
} else {
writeln!(&mut w, "signal == 1")?;
}
} else if signal_is_float_in_rust(signal) {
// Scaling is always done on floats
writeln!(&mut w, "let factor = {}_f32;", signal.factor)?;
Expand Down