Speeduino
Loading...
Searching...
No Matches
pages.h
Go to the documentation of this file.
1#pragma once
2#include <Arduino.h>
3#include "table3d.h"
4#include "config_pages.h"
5
10
11// These are the page numbers that the Tuner Studio serial protocol uses to transverse the different map and config pages.
12constexpr uint8_t veMapPage = 2;
13constexpr uint8_t veSetPage = 1; //Note that this and the veMapPage were swapped in Feb 2019 as the 'algorithm' field must be declared in the ini before it's used in the fuel table
14constexpr uint8_t ignMapPage = 3;
15constexpr uint8_t ignSetPage = 4;
16constexpr uint8_t afrMapPage = 5;
17constexpr uint8_t afrSetPage = 6;
18constexpr uint8_t boostvvtPage = 7;
19constexpr uint8_t seqFuelPage = 8;
20constexpr uint8_t canbusPage = 9;
21constexpr uint8_t warmupPage = 10;
22constexpr uint8_t fuelMap2Page = 11;
23constexpr uint8_t wmiMapPage = 12;
24constexpr uint8_t progOutsPage = 13;
25constexpr uint8_t ignMap2Page = 14;
26constexpr uint8_t boostvvtPage2 = 15;
29
31void setTuneToEmpty(void);
32
33// ============================== Per-byte page access ==========================
34
38 );
39
47 byte value
48 );
49
50
51// ============================== Page Iteration ==========================
52
53// A logical TS page is actually multiple in memory entities. Allow iteration
54// over those entities.
55
56// Type of entity
57enum class EntityType : uint8_t {
58 Raw, // A block of memory
59 Table, // A 3D table
60 NoEntity, // No entity, but a valid offset
61 End // The offset was past any known entity for the page
62};
63
66 uint8_t page; // The index of the page the entity belongs to
67 uint8_t index; // The sub-index of the item within the page
68
69 constexpr entity_page_location_t(void)
70 : page(0U)
71 , index(0U)
72 {
73 }
79
81 {
82 return lhs.page==rhs.page
83 && lhs.index==rhs.index;
84 }
85
87 {
88 return !(lhs==rhs);
89 }
90};
91
94 uint16_t start; // The start position of the entity, in bytes, from the start of the page
95 uint16_t size; // Size of the entity in bytes
96
97 constexpr entity_page_address_t(void)
98 : start(0U)
99 , size(0U)
100 {
101 }
103 : start(base)
104 , size(length)
105 {
106 }
107
115 {
116 return offset >= start && offset < start+size;
117 }
118
123};
124
125// A entity on a logical page.
127 union
128 {
129 table3d_t *pTable; // If the entity is a table, this points to the table
130 config_page_t *pRaw; // If the entity is a raw block, this points to it
131 };
136
137 constexpr page_iterator_t()
138 : pTable(nullptr)
140 {
141 }
142
149
150 void setNoEntity(void)
151 {
152 pRaw = nullptr;
155 }
156
163
170};
171
172// ============================== Per-byte entity access ==========================
173
177 );
178
185 byte value
186 );
187
193
198
203
208
213
Iterate over table axis elements.
Definition table3d_axes.h:31
Iterate through a tables values, row by row.
Definition table3d_values.h:87
The tune page structs and related defines.
static TIntegral readSerialIntegralTimeout(void)
Reads an integral type, timing out if necessary.
Definition comms.cpp:175
TableType
Table type identifiers. Limited compile time RTTI.
Definition table3d.h:69
table_axis_iterator y_begin(const page_iterator_t &it)
Definition pages.cpp:545
constexpr uint8_t afrSetPage
Definition pages.h:17
void setTuneToEmpty(void)
Fill the tune (config pages & tables) with zeroes.
Definition pages.cpp:469
constexpr uint8_t ignMap2Page
Definition pages.h:25
constexpr uint8_t ignSetPage
Definition pages.h:15
constexpr uint8_t boostvvtPage
Definition pages.h:18
constexpr uint8_t veMapPage
Definition pages.h:12
constexpr uint8_t ignMapPage
Definition pages.h:14
constexpr uint8_t fuelMap2Page
Definition pages.h:22
page_iterator_t page_begin(uint8_t pageNum)
Definition pages.cpp:508
constexpr uint8_t seqFuelPage
Definition pages.h:19
bool setPageValue(uint8_t pageNum, uint16_t offset, byte value)
Sets a single value from a page, with data aligned as per the ini file.
Definition pages.cpp:490
constexpr uint8_t MIN_PAGE_NUM
Definition pages.h:27
table_value_iterator rows_begin(const page_iterator_t &it)
Definition pages.cpp:521
constexpr uint8_t veSetPage
Definition pages.h:13
constexpr uint8_t canbusPage
Definition pages.h:20
uint16_t getPageSize(uint8_t pageNum)
Definition pages.cpp:479
page_iterator_t advance(const page_iterator_t &it)
Definition pages.cpp:513
constexpr uint8_t warmupPage
Definition pages.h:21
bool setEntityValue(page_iterator_t &entity, uint16_t offset, byte value)
Sets a single value from a page, with data aligned as per the ini file.
Definition pages.cpp:246
table_axis_iterator x_begin(const page_iterator_t &it)
Definition pages.cpp:529
byte getEntityValue(const page_iterator_t &entity, uint16_t offset)
Gets a single value from an entity, with data aligned as per the ini file.
Definition pages.cpp:205
constexpr uint8_t boostvvtPage2
Definition pages.h:26
constexpr uint8_t wmiMapPage
Definition pages.h:23
table_axis_iterator x_rbegin(const page_iterator_t &it)
Definition pages.cpp:537
EntityType
Definition pages.h:57
constexpr uint8_t afrMapPage
Definition pages.h:16
byte getPageValue(uint8_t pageNum, uint16_t offset)
Gets a single value from a page, with data aligned as per the ini file.
Definition pages.cpp:497
constexpr uint8_t MAX_PAGE_NUM
Definition pages.h:28
constexpr uint8_t progOutsPage
Definition pages.h:24
Definition config_pages.h:166
Position and size of an entity within a page.
Definition pages.h:93
entity_page_address_t next(uint16_t nextBlockSize) const
Definition pages.h:119
uint16_t start
Definition pages.h:94
constexpr entity_page_address_t(uint16_t base, uint16_t length)
Definition pages.h:102
bool isOffsetInEntity(uint16_t offset) const
Check if the offset is within the entity address range.
Definition pages.h:114
constexpr entity_page_address_t(void)
Definition pages.h:97
uint16_t size
Definition pages.h:95
The unique location of an entity within all pages.
Definition pages.h:65
uint8_t page
Definition pages.h:66
uint8_t index
Definition pages.h:67
friend bool operator!=(const entity_page_location_t &lhs, const entity_page_location_t &rhs)
Definition pages.h:86
friend bool operator==(const entity_page_location_t &lhs, const entity_page_location_t &rhs)
Definition pages.h:80
constexpr entity_page_location_t(void)
Definition pages.h:69
constexpr entity_page_location_t(uint8_t pageNum, uint8_t pageSubIndex)
Definition pages.h:74
Definition pages.h:126
config_page_t * pRaw
Definition pages.h:130
table3d_t * pTable
Definition pages.h:129
EntityType type
Definition pages.h:132
page_iterator_t(EntityType theType, const entity_page_location_t &entityLocation, const entity_page_address_t &entityAddress)
Definition pages.h:143
entity_page_location_t location
Definition pages.h:134
entity_page_address_t address
Definition pages.h:135
TableType table_key
Definition pages.h:133
void setNoEntity(void)
Definition pages.h:150
void setTable(table3d_t *table, TableType key)
Definition pages.h:157
constexpr page_iterator_t()
Definition pages.h:137
void setRaw(config_page_t *pBuffer)
Definition pages.h:164
Definition table3d.h:79
3D table data types and functions