persist_conf.h
1 /*
2  * EEZ PSU Firmware
3  * Copyright (C) 2015-present, Envox d.o.o.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 namespace eez {
22 namespace psu {
23 
24 class Channel;
25 
26 namespace profile {
27 
28 struct Parameters;
29 
30 }
31 }
32 } // namespace eez::psu::profile
33 
34 namespace eez {
35 namespace psu {
37 namespace persist_conf {
38 
40 struct BlockHeader {
41  uint32_t checksum;
42  uint16_t version;
43 };
44 
46 struct DeviceFlags {
47  unsigned isSoundEnabled : 1;
48  unsigned dateValid : 1;
49  unsigned timeValid : 1;
50  unsigned profileAutoRecallEnabled : 1;
51  unsigned dst : 1;
52  unsigned channelsViewMode : 3;
53  unsigned ethernetEnabled : 1;
54  unsigned outputProtectionCouple : 1;
55  unsigned shutdownWhenProtectionTripped : 1;
56  unsigned forceDisablingAllOutputsOnPowerUp : 1;
57  unsigned isFrontPanelLocked: 1;
58  unsigned isClickSoundEnabled : 1;
59  unsigned reserved: 18;
60 };
61 
64  BlockHeader header;
65  char serialNumber[7 + 1];
66  char calibration_password[PASSWORD_MAX_LENGTH + 1];
67  DeviceFlags flags;
68  uint8_t date_year;
69  uint8_t date_month;
70  uint8_t date_day;
71  uint8_t time_hour;
72  uint8_t time_minute;
73  uint8_t time_second;
74  int16_t time_zone;
75  int8_t profile_auto_recall_location;
76  int8_t touch_screen_cal_orientation;
77  int16_t touch_screen_cal_tlx;
78  int16_t touch_screen_cal_tly;
79  int16_t touch_screen_cal_brx;
80  int16_t touch_screen_cal_bry;
81  int16_t touch_screen_cal_trx;
82  int16_t touch_screen_cal_try;
83 #ifdef EEZ_PSU_SIMULATOR
84  bool gui_opened;
85 #endif // EEZ_PSU_SIMULATOR
86 };
87 
89 struct DeviceFlags2 {
90  unsigned encoderConfirmationMode : 1;
91  unsigned displayState: 1;
92  unsigned triggerContinuousInitializationEnabled: 1;
93  unsigned reserved: 29;
94 };
95 
97  BlockHeader header;
98  char systemPassword[PASSWORD_MAX_LENGTH + 1];
99  DeviceFlags2 flags;
100  uint8_t encoderMovingSpeedDown;
101  uint8_t encoderMovingSpeedUp;
102  uint8_t displayBrightness;
103  uint8_t triggerSource;
104  float triggerDelay;
105  uint8_t triggerPolarity;
106  uint8_t reserverd[87];
107 };
108 
109 extern DeviceConfiguration devConf;
110 extern DeviceConfiguration2 devConf2;
111 
112 void loadDevice();
113 bool saveDevice();
114 
115 void loadDevice2();
116 bool saveDevice2();
117 
118 bool isSystemPasswordValid(const char *new_password, size_t new_password_len, int16_t &err);
119 bool changeSystemPassword(const char *new_password, size_t new_password_len);
120 
121 bool isCalibrationPasswordValid(const char *new_password, size_t new_password_len, int16_t &err);
122 bool changeCalibrationPassword(const char *new_password, size_t new_password_len);
123 
124 bool changeSerial(const char *newSerialNumber, size_t newSerialNumberLength);
125 
126 bool enableSound(bool enable);
127 bool isSoundEnabled();
128 
129 bool enableClickSound(bool enable);
130 bool isClickSoundEnabled();
131 
132 bool enableEthernet(bool enable);
133 bool isEthernetEnabled();
134 
135 bool readSystemDate(uint8_t &year, uint8_t &month, uint8_t &day);
136 void writeSystemDate(uint8_t year, uint8_t month, uint8_t day);
137 
138 bool enableProfileAutoRecall(bool enable);
139 bool isProfileAutoRecallEnabled();
140 bool setProfileAutoRecallLocation(int location);
141 int getProfileAutoRecallLocation();
142 
143 bool readSystemTime(uint8_t &hour, uint8_t &minute, uint8_t &second);
144 void writeSystemTime(uint8_t hour, uint8_t minute, uint8_t second);
145 
146 void writeSystemDateTime(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second);
147 
148 void toggleChannelsViewMode();
149 
150 void loadChannelCalibration(Channel *channel);
151 bool saveChannelCalibration(Channel *channel);
152 
153 bool loadProfile(int location, profile::Parameters *profile);
154 bool saveProfile(int location, profile::Parameters *profile);
155 
156 uint32_t readTotalOnTime(int type);
157 bool writeTotalOnTime(int type, uint32_t time);
158 
159 bool enableOutputProtectionCouple(bool enable);
160 bool isOutputProtectionCoupleEnabled();
161 
162 bool enableShutdownWhenProtectionTripped(bool enable);
163 bool isShutdownWhenProtectionTrippedEnabled();
164 
165 bool enableForceDisablingAllOutputsOnPowerUp(bool enable);
166 bool isForceDisablingAllOutputsOnPowerUpEnabled();
167 
168 bool lockFrontPanel(bool lock);
169 
170 bool setEncoderSettings(uint8_t confirmationMode, uint8_t movingSpeedDown, uint8_t movingSpeedUp);
171 
172 bool setDisplayState(unsigned state);
173 
174 }
175 }
176 } // namespace eez::psu::persist_conf
Namespace for the everything from the EEZ.
Definition: actions.cpp:41
Profile parameters.
Definition: profile.h:82
Device configuration block.
Definition: persist_conf.h:63
Device binary flags stored in DeviceConfiguration.
Definition: persist_conf.h:89
PSU channel.
Definition: channel.h:62
#define PASSWORD_MAX_LENGTH
Password maximum length in number of characters.
Definition: conf_advanced.h:79
Device binary flags stored in DeviceConfiguration.
Definition: persist_conf.h:46
Header of the every block stored in EEPROM. It contains checksum and version.
Definition: persist_conf.h:40