Skip to content
Snippets Groups Projects
Commit e1cbf643 authored by Benjamin Koch's avatar Benjamin Koch
Browse files

try features and groups in program info

parent 7855909a
No related branches found
No related tags found
No related merge requests found
...@@ -760,5 +760,12 @@ pub static PROGRAM_INFO: [u8; 4096] = { ...@@ -760,5 +760,12 @@ pub static PROGRAM_INFO: [u8; 4096] = {
(28, "Current Measurement Channel 1"), (28, "Current Measurement Channel 1"),
(29, "VCC Measurement"), (29, "VCC Measurement"),
]) ])
.program_feature("abc")
.program_feature("abc2")
.program_feature("abc 3")
.program_feature_group_with_flags(['C', '3'], 2, "def", heizung::program_info::GroupFlags::ADVANCED)
.feature("abc 4")
.feature("abc 5")
.group_done()
.build() .build()
}; };
...@@ -7,6 +7,12 @@ pub struct ProgramInfoBuilder { ...@@ -7,6 +7,12 @@ pub struct ProgramInfoBuilder {
data_end_offset: usize, data_end_offset: usize,
} }
pub struct ProgramInfoBuilderForGroup {
builder: ProgramInfoBuilder,
tag: [char; 2],
id: u32,
}
#[repr(u16)] #[repr(u16)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
...@@ -225,13 +231,13 @@ impl ProgramInfoBuilder { ...@@ -225,13 +231,13 @@ impl ProgramInfoBuilder {
.push_string(value) .push_string(value)
} }
const fn bi_named_group(self: Self, tag: [char; 2], id: u32, flags: u16, group_tag: u16, group_id: u32, label: &str) -> Self { const fn bi_named_group(self: Self, tag: [char; 2], id: u32, flags: u16, group_tag: [char; 2], group_id: u32, label: &str) -> Self {
self.push_current_info_ptr() self.push_current_info_ptr()
.push_u16(Self::BINARY_INFO_TYPE_NAMED_GROUP) .push_u16(Self::BINARY_INFO_TYPE_NAMED_GROUP)
.push_tag(tag) .push_tag(tag)
.push_u32(id) .push_u32(id)
.push_u16(flags) .push_u16(flags)
.push_u16(group_tag) .push_tag(group_tag)
.push_u32(group_id) .push_u32(group_id)
.push_string(label) .push_string(label)
} }
...@@ -312,12 +318,13 @@ impl ProgramInfoBuilder { ...@@ -312,12 +318,13 @@ impl ProgramInfoBuilder {
pub const fn boot2_name(self: Self, attr: &str) -> Self { pub const fn boot2_name(self: Self, attr: &str) -> Self {
self.bi_string(Self::BINARY_INFO_TAG_RASPBERRY_PI, Self::BINARY_INFO_ID_RP_BOOT2_NAME, attr) self.bi_string(Self::BINARY_INFO_TAG_RASPBERRY_PI, Self::BINARY_INFO_ID_RP_BOOT2_NAME, attr)
} }
pub const fn program_feature_group(self: Self, tag: u16, id: u32, label: &str) -> Self { pub const fn program_feature_group(self: Self, tag: [char; 2], id: u32, label: &str) -> ProgramInfoBuilderForGroup {
self.program_feature_group_with_flags(tag, id, label, GroupFlags::NONE) self.program_feature_group_with_flags(tag, id, label, GroupFlags::NONE)
} }
pub const fn program_feature_group_with_flags(self: Self, tag: u16, id: u32, label: &str, flags: GroupFlags) -> Self { pub const fn program_feature_group_with_flags(self: Self, tag: [char; 2], id: u32, label: &str, flags: GroupFlags) -> ProgramInfoBuilderForGroup {
self.bi_named_group(Self::BINARY_INFO_TAG_RASPBERRY_PI, Self::BINARY_INFO_ID_RP_PROGRAM_FEATURE, let builder = self.bi_named_group(Self::BINARY_INFO_TAG_RASPBERRY_PI, Self::BINARY_INFO_ID_RP_PROGRAM_FEATURE,
flags as u16, tag, id, label) flags as u16, tag, id, label);
ProgramInfoBuilderForGroup { builder, tag, id }
} }
pub const fn pins_with_func(self: Self, func: PinFunction, pins: &[u8]) -> Self { pub const fn pins_with_func(self: Self, func: PinFunction, pins: &[u8]) -> Self {
...@@ -374,3 +381,13 @@ impl ProgramInfoBuilder { ...@@ -374,3 +381,13 @@ impl ProgramInfoBuilder {
append_names(self, pins, 1) append_names(self, pins, 1)
} }
} }
impl ProgramInfoBuilderForGroup {
pub const fn feature(mut self: Self, name: &str) -> Self {
self.builder = self.builder.bi_string(self.tag, self.id, name);
self
}
pub const fn group_done(self: Self) -> ProgramInfoBuilder {
self.builder
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment