Skip to content

Commit

Permalink
little code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cedel1 committed Jul 18, 2023
1 parent 2d5db61 commit 3f44a18
Show file tree
Hide file tree
Showing 15 changed files with 2 additions and 54 deletions.
Binary file modified SCPI_manual/smartpower3_scpi_manual.pdf
Binary file not shown.
6 changes: 0 additions & 6 deletions SCPI_manual/smartpower3_scpi_manual.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
\documentclass[a4paper,10pt]{article}
\usepackage[left=2.5cm,right=2.5cm,top=2cm]{geometry}
%\usepackage[T1]{fontenc}
\usepackage{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
Expand All @@ -17,8 +16,6 @@
\usepackage{textcomp}
\usepackage{listings}
\usepackage{hyperref}
%\usepackage{glossaries}
%\usepackage{parskip}

\title{Hardkernel SmartPower3 SCPI manual}
\author{Lukáš Říha}
Expand Down Expand Up @@ -343,9 +340,6 @@ \section{Commands}
\begin{description}
This query returns the output states of channel \verb!#!. Returns 0 or 1.
\end{description}

%/*{ "SYSTem:COMMunication:TCPIP:CONTROL?", SCPI_SystemCommTcpipControlQ, 0 },*/

\end{enumerate}
\end{enumerate}

Expand Down
1 change: 0 additions & 1 deletion smartpower3/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class Component
void setTextColor(uint16_t fg_color, uint16_t bg_color);
void loadFont(const uint8_t font[]);
void unloadFont(void);
//void clearAndDrawWithFont(const uint8_t font[], String string_to_draw);
void clearAndDrawWithColoredFont(const uint8_t font[], uint16_t fg_color, const char* string_to_draw);
void clearAndDrawWithFont(const uint8_t font[], const char* string_to_draw);
private:
Expand Down
3 changes: 1 addition & 2 deletions smartpower3/inputmanager.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#include <ESP32Encoder.h>
#include <Arduino.h>
//#include <FunctionalInterrupt.h>


#define DEBOUNCE_TIME 100
#define LONG_PRESS_TIME 3000

void countEncoder(void *val);
void initEncoder(void *param);


struct dial_t {
int8_t cnt;
int8_t direct;
Expand Down
5 changes: 0 additions & 5 deletions smartpower3/meas_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ void MeasChannels::sample()
A = A * 100 / 65536;
A = A / rsense * 1000000;

/* Serial.printf("%6.10f\n\r", V);
Serial.printf("%6.10f\n\r", A);
Serial.printf("%d\n\r", static_cast<uint16_t>(V));
Serial.printf("%d\n\r", static_cast<uint16_t>(A));*/

switch (i) {
case 0:
channel0->update(V, A);
Expand Down
2 changes: 0 additions & 2 deletions smartpower3/scpimanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ scpi_result_t SCPIManager::DMM_MeasureUnitDcQ(scpi_t *context, scpi_unit_t allow
{
const uint8_t max_param_count = 3;
UserContext *user_ctx = static_cast<UserContext *>(context->user_context);
//Settings *settings = user_ctx->settings;
MeasChannels *channels = user_ctx->measuring_channels;
//ScreenManager *sm = user_ctx->screen_manager;
scpi_number_t expected_value;
scpi_number_t resolution;
scpi_parameter_t working_param;
Expand Down
11 changes: 1 addition & 10 deletions smartpower3/scpimanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class SCPIManager
{ "*OPC", SCPI_CoreOpc, 0 },
{ "*OPC?", SCPI_CoreOpcQ, 0 },
//TODO: Check if reset is complete or needs rework
//{ "*RST", SCPI_CoreRst, 0 },
{ "*RST", Reset, 0 },
{ "*SRE", SCPI_CoreSre, 0 },
{ "*SRE?", SCPI_CoreSreQ, 0 },
Expand Down Expand Up @@ -163,7 +162,7 @@ class SCPIManager
{"SYSTem:COMMunicate:NETwork:GATE?", SCPI_NetworkGateQ, 0 },
// This command sets the Gateway IP address of the Ethernet module of the power supply.
// The Gateway IP defaults to 0.0.0.0 in absence of a DHCP server.
// Gateway IP address is represented with 4 bytes each having a range of 0-255 separated by dots
// Gateway IP address is represented with 4 bytes each having a range of 0-255 separated by dots
{"SYSTem:COMMunicate:NETwork:SUBNet", SCPI_NetworkSubnet, 0 },
{"SYSTem:COMMunicate:NETwork:SUBNet?", SCPI_NetworkSubnetQ, 0 },
// This command sets the subnet IP Mask address of the Ethernet module of the power supply.
Expand Down Expand Up @@ -195,12 +194,6 @@ class SCPIManager
{"SYSTem:COMMunicate:Serial:FEED", SCPI_SerialFeed, 0},
{"SYSTem:COMMunicate:Serial:FEED?", SCPI_SerialFeedQ, 0},

//{"[SYSTem][:COMMunicate]:SERial:FEED", SCPI_SocketPortQ, 0 }
//{"[SYSTem][:COMMunicate]:SERial:FEED?", SCPI_SocketPortQ, 0 }
//{"[SYSTem][:COMMunicate]:SOCKet:FEED", SCPI_SocketPort, 0 },
//{"[SYSTem][:COMMunicate]:SOCKet:FEED?", SCPI_SocketPortQ, 0 },


//{"STATus:OPERation?", scpi_stub_callback, 0},
//{"STATus:OPERation:EVENt?", scpi_stub_callback, 0},
//{"STATus:OPERation:CONDition?", scpi_stub_callback, 0},
Expand All @@ -227,8 +220,6 @@ class SCPIManager
{ "OUTPut#[:STATe]", Output_TurnOnOff, 0 },
{ "OUTPut#[:STATe]?", Output_TurnOnOffQ, 0 },

/*{ "SYSTem:COMMunication:TCPIP:CONTROL?", SCPI_SystemCommTcpipControlQ, 0 },*/

SCPI_CMD_LIST_END
};
};
Expand Down
2 changes: 0 additions & 2 deletions smartpower3/screenmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,3 @@ class ScreenManager
Screen *screens[LAST_SCREEN_COUNT] = {};
bool show_next_screen = false;
};

//ScreenManager screen_manager;
5 changes: 0 additions & 5 deletions smartpower3/screens/networkscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ enum network_screen_state_setting {
STATE_NETWORK_WIFI_ICON = 1,
STATE_NETWORK_LOGGING_ICON,
STATE_NETWORK_DHCP,
// STATE_NETWORK_MODE,
// STATE_LOG_INTERVAL,
// STATE_BAUD_RATE,
// STATE_BL,
};


Expand All @@ -51,7 +47,6 @@ class NetworkScreen : public Screen
void drawGatewayIpaddr(const char* ipaddr);
void drawSubnetMask(const char* ipaddr);
void drawDnsServers(const char* ipaddr_dns1, const char* ipaddr_dns2);
//void drawMode(device_operation_mode default_mode = OPERATION_MODE_DEFAULT);

void onEnter(void);
void debug(void);
Expand Down
1 change: 0 additions & 1 deletion smartpower3/screens/settingscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ void SettingScreen::changeOperationMode(device_operation_mode operation_mode)
{
drawMode(operation_mode);
operation_mode_edit = operation_mode;
//changeOperationMode(operation_mode);
}

void SettingScreen::selectBLLevel(uint16_t rectangle_color)
Expand Down
7 changes: 0 additions & 7 deletions smartpower3/screens/settingscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
#define X_IPADDR 226
#define X_SSID 172

/*#define LINE_SPACING 42
#define RIGHT_POSITION_X 460*/


enum setting_screen_mode_t {
SETTING_SETTING = 0,
Expand All @@ -39,7 +36,6 @@ enum setting_screen_mode_t {
SETTING_SETTING_OPERATION_MODE,
};


enum screen_state_setting {
STATE_SETTING_WIFI_ICON = 1,
STATE_SETTING_LOGGING_ICON,
Expand Down Expand Up @@ -106,7 +102,6 @@ class SettingScreen : public Screen
void drawSerialBaud(uint32_t serial_baud);
void drawSerialLoggingEnabled(bool is_enabled=true);
void drawWifiLoggingEnabled(bool is_enabled=true);
//void popUp(void);

void drawUDPIpaddr(const char* ipaddr);
void drawUDPport(uint16_t port);
Expand All @@ -119,7 +114,6 @@ class SettingScreen : public Screen
void debug(void);
private:
setting_screen_mode_t mode = SETTING_SETTING;
//TFT_eSprite *popup;
uint16_t x;
uint16_t y;
uint8_t backlight_level_preset = 0;
Expand All @@ -133,7 +127,6 @@ class SettingScreen : public Screen
uint32_t serial_baud_edit = 0;
device_operation_mode operation_mode;
device_operation_mode operation_mode_edit;
//device_operation_mode operation_mode = OPERATION_MODE_DEFAULT;
Component *com_serial_baud;
Component *com_log_interval;
Component *com_ssid;
Expand Down
6 changes: 0 additions & 6 deletions smartpower3/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,14 @@ void Settings::init()
this->serial_baud_rate = this->getSerialBaudRate(true);
// Logging related
this->logging_enabled = this->isLoggingEnabled(true);
//this->log_interval_index = this->getLogIntervalIndex(true);
this->log_interval = this->getLogInterval(true);
this->wifi_ipv4_udp_logging_server_ip_address = this->getWifiIpv4UdpLoggingServerIpAddress(true);
this->wifi_ipv4_udp_logging_server_port = this->getWifiIpv4UdpLoggingServerPort(true);
// WiFI related
this->wifi_enabled = this->isWifiEnabled(true);
this->mac_address = this->getMacAddress();
//this->wifi_use_ipv4 = true;
//bool wifi_use_ipv6 = false;
this->wifi_access_point_ssid = this->getWifiAccessPointSsid(true);
this->wifi_password = this->getWifiPassword(true);
//TODO: add settings/checking CREDENTIALS_STATE
/*this->wifi_credentials_checked = this->isWifiCredentialsChecked();
this->wifi_ipv4_connect_automatically = true;*/
this->wifi_ipv4_dhcp_enabled = this->isWifiIpv4DhcpEnabled(true);
this->wifi_ipv4_static_ip = this->getWifiIpv4StaticIp(true);
this->wifi_ipv4_gateway_address = this->getWifiIpv4GatewayAddress(true);
Expand Down
3 changes: 0 additions & 3 deletions smartpower3/smartpower3.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <meas_channel.h>
#include <Microchip_PAC193x.h>
//#include <screenmanager.h>
#include "inputmanager.h"
#include "settings.h"
#include "wifimanager.h"
Expand Down Expand Up @@ -44,5 +43,3 @@ TaskHandle_t screen_handle;
TaskHandle_t input_handle;
TaskHandle_t button_handle;
TaskHandle_t log_handle;
//TaskHandle_t encoder_handle;

2 changes: 0 additions & 2 deletions smartpower3/smartpower3.ino
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,11 @@ void loop() {
screen_manager.dimmingLED(1);
}
#ifdef TASK_STACK_HIGH_WATERMARK_SERIAL_PRINT
//Serial.printf("Loop: %u\n\r", uxTaskGetStackHighWaterMark(NULL));
Serial.printf("WiFi task: %u\n\r", uxTaskGetStackHighWaterMark(wifi_handle));
Serial.printf("Screen task: %u\n\r", uxTaskGetStackHighWaterMark(screen_handle));
Serial.printf("Button task: %u\n\r", uxTaskGetStackHighWaterMark(button_handle));
Serial.printf("Input task: %u\n\r", uxTaskGetStackHighWaterMark(input_handle));
Serial.printf("Log task: %u\n\r", uxTaskGetStackHighWaterMark(log_handle));
//Serial.printf("Encoder task: %u\n\r", uxTaskGetStackHighWaterMark(encoder_handle));
#endif
#ifdef HEAP_INFO_SERIAL_PRINT
heap_caps_print_heap_info(MALLOC_CAP_8BIT);
Expand Down
2 changes: 0 additions & 2 deletions smartpower3/wifimanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ class WiFiManager
void apDisconnectAndTurnWiFiOff(void);
void apInfo(void);
String apInfoSaved(void);
//char* apInfoSaved(void);
String apInfoConnected(void);
//char apInfoConnected(void);
void udpServerInfo();
void udpServerForget(void);
void switchWiFiConnection(void);
Expand Down

0 comments on commit 3f44a18

Please sign in to comment.