mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 15:36:38 +02:00
* compiles with PlatformIO
This commit is contained in:
parent
b9cec55849
commit
aeb63f5d31
15 changed files with 39 additions and 335 deletions
5
tools/esp8266/.gitignore
vendored
Normal file
5
tools/esp8266/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
|
@ -84,8 +84,7 @@ void app::setup(uint32_t timeout) {
|
|||
DPRINTLN(DBG_INFO, F("add inverter: ") + String(name) + ", SN: " + String(invSerial, HEX));
|
||||
|
||||
for(uint8_t j = 0; j < 4; j++) {
|
||||
mEep->read(ADDR_INV_CH_NAME + (i * 4 * MAX_NAME_LENGTH) + j * MAX_NAME_LENGTH, name, MAX_NAME_LENGTH);
|
||||
snprintf(iv->chName[j], MAX_NAME_LENGTH, "%s", name);
|
||||
mEep->read(ADDR_INV_CH_NAME + (i * 4 * MAX_NAME_LENGTH) + j * MAX_NAME_LENGTH, iv->chName[j], MAX_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,7 +374,7 @@ void app::handleIntr(void) {
|
|||
//-----------------------------------------------------------------------------
|
||||
bool app::buildPayload(uint8_t id) {
|
||||
DPRINTLN(DBG_VERBOSE, F("app::buildPayload"));
|
||||
uint16_t crc = 0xffff, crcRcv;
|
||||
uint16_t crc = 0xffff, crcRcv = 0x0000;
|
||||
if(mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
|
||||
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#ifndef __APP_H__
|
||||
#define __APP_H__
|
||||
|
||||
#include "main.h"
|
||||
#include <RF24.h>
|
||||
#include <RF24_config.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "CircularBuffer.h"
|
||||
#include "hmSystem.h"
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 4
|
||||
#define VERSION_PATCH 21
|
||||
#define VERSION_PATCH 22
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
|
|
|
@ -3,19 +3,18 @@
|
|||
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <Ticker.h>
|
||||
|
||||
#include <ESP8266HTTPUpdateServer.h>
|
||||
#include "dbg.h"
|
||||
#include "app.h"
|
||||
#include "config.h"
|
||||
|
||||
app myApp;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IRAM_ATTR void handleIntr(void) {
|
||||
myApp.handleIntr();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void setup() {
|
||||
myApp.setup(WIFI_TRY_CONNECT_TIME);
|
||||
|
@ -29,9 +28,3 @@ void setup() {
|
|||
void loop() {
|
||||
myApp.loop();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
ICACHE_RAM_ATTR void handleIntr(void) {
|
||||
myApp.handleIntr();
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef __HM_DEFINES_H__
|
||||
#define __HM_DEFINES_H__
|
||||
|
||||
#include "debug.h"
|
||||
#include "dbg.h"
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef __RADIO_H__
|
||||
#define __RADIO_H__
|
||||
|
||||
#include "dbg.h"
|
||||
#include <RF24.h>
|
||||
#include <RF24_config.h>
|
||||
#include "crc.h"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef __MAIN_H__
|
||||
#define __MAIN_H__
|
||||
|
||||
#include "dbg.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
|
@ -21,7 +22,6 @@
|
|||
#include "eep.h"
|
||||
#include "defines.h"
|
||||
#include "crc.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
const byte mDnsPort = 53;
|
||||
|
@ -108,8 +108,9 @@ class Main {
|
|||
uint16_t max;
|
||||
uint8_t frag;
|
||||
ESP.getHeapStats(&free, &max, &frag);
|
||||
|
||||
Serial.printf("free: 0x%x - max: 0x%x - frag: %d%%\n", free, max, frag);
|
||||
DPRINT(DBG_VERBOSE, F("free: ") + String(free));
|
||||
DPRINT(DBG_VERBOSE, F(" - max: ") + String(max) + "%");
|
||||
DPRINTLN(DBG_VERBOSE, F(" - frag: ") + String(frag));
|
||||
}
|
||||
|
||||
char mStationSsid[SSID_LEN];
|
||||
|
|
|
@ -21,9 +21,7 @@ class mqtt {
|
|||
memset(mTopic, 0, MQTT_TOPIC_LEN);
|
||||
}
|
||||
|
||||
~mqtt() {
|
||||
delete mClient;
|
||||
}
|
||||
~mqtt() { }
|
||||
|
||||
void setup(const char *broker, const char *topic, const char *user, const char *pwd, uint16_t port) {
|
||||
DPRINTLN(DBG_VERBOSE, F("mqtt.h:setup"));
|
||||
|
|
16
tools/esp8266/platformio.ini
Normal file
16
tools/esp8266/platformio.ini
Normal file
|
@ -0,0 +1,16 @@
|
|||
[platformio]
|
||||
src_dir = .
|
||||
|
||||
[env:d1_mini]
|
||||
platform = espressif8266
|
||||
framework = arduino
|
||||
board = d1_mini
|
||||
monitor_speed = 115200
|
||||
board_build.f_cpu = 80000000L
|
||||
;build_flags = -DDEBUG_ESP_PORT=Serial
|
||||
|
||||
lib_deps =
|
||||
RF24
|
||||
PubSubClient
|
||||
Time
|
||||
ESP Async WebServer
|
|
@ -1,31 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32002.261
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hmClassTest", "hmClassTest\hmClassTest.vcxproj", "{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Debug|x64.Build.0 = Debug|x64
|
||||
{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Debug|x86.Build.0 = Debug|Win32
|
||||
{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Release|x64.ActiveCfg = Release|x64
|
||||
{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Release|x64.Build.0 = Release|x64
|
||||
{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Release|x86.ActiveCfg = Release|Win32
|
||||
{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7C291F74-09F6-4C84-99E1-6E7294062385}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,147 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\main.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{4d899c12-de0e-4cdb-b48c-fdfec331f219}</ProjectGuid>
|
||||
<RootNamespace>hmClassTest</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Quelldateien">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Headerdateien">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Ressourcendateien">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\main.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
|
@ -1,105 +0,0 @@
|
|||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#define MAX_NUM_INVERTERS 3
|
||||
#define MAX_NAME_LENGTH 16
|
||||
#define NDEBUG
|
||||
#define NO_RADIO
|
||||
|
||||
#include "../../../hmDefines.h"
|
||||
#include "../../../hmInverter.h"
|
||||
#include "../../../hmSystem.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef int RadioType;
|
||||
typedef int BufferType;
|
||||
typedef Inverter<float> InverterType;
|
||||
typedef HmSystem<RadioType, BufferType, MAX_NUM_INVERTERS, InverterType> HmSystemType;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void valToBuf(InverterType *iv, uint8_t fld, uint8_t ch, float val, uint8_t bufPos);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int main(int argc, char* argv[]) {
|
||||
HmSystemType sys;
|
||||
InverterType *iv0, *iv1;
|
||||
uint8_t buf[30] = { 0xcc };
|
||||
|
||||
iv0 = sys.addInverter("HM1200", 0x1122334455ULL, INV_TYPE_HM1200);
|
||||
iv1 = sys.addInverter("HM600", 0x1234567891ULL, INV_TYPE_HM600);
|
||||
|
||||
valToBuf(iv0, FLD_UDC, CH1, 29.5, 3);
|
||||
valToBuf(iv0, FLD_UDC, CH3, 30.6, 9);
|
||||
valToBuf(iv0, FLD_YD, CH1, 1234, 5);
|
||||
valToBuf(iv0, FLD_YD, CH2, 1199, 7);
|
||||
valToBuf(iv0, FLD_YD, CH3, 899, 11);
|
||||
valToBuf(iv0, FLD_YD, CH4, 932, 13);
|
||||
valToBuf(iv0, FLD_YT, CH1, 40.123, 13);
|
||||
valToBuf(iv0, FLD_YT, CH2, 57.231, 1);
|
||||
valToBuf(iv0, FLD_YT, CH3, 59.372, 3);
|
||||
valToBuf(iv0, FLD_YT, CH4, 43.966, 7);
|
||||
|
||||
iv0->doCalculations();
|
||||
for(uint8_t i = 0; i < iv0->listLen; i ++) {
|
||||
float val = iv0->getValue(i);
|
||||
if(0.0 != val) {
|
||||
printf("%10s [CH%d] = %.3f %s\n", iv0->getFieldName(i), iv0->getChannel(i), val, iv0->getUnit(i));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void valToBuf(InverterType *iv, uint8_t fld, uint8_t ch, float val, uint8_t bufPos) {
|
||||
uint8_t buf[30] = { 0xcc };
|
||||
uint8_t len;
|
||||
uint16_t factor;
|
||||
|
||||
switch(fld) {
|
||||
default: len = 2; break;
|
||||
case FLD_YT: len = 4; break;
|
||||
}
|
||||
|
||||
switch(fld) {
|
||||
case FLD_YD: factor = 1; break;
|
||||
case FLD_UDC:
|
||||
case FLD_PDC:
|
||||
case FLD_UAC:
|
||||
case FLD_PAC:
|
||||
case FLD_PCT:
|
||||
case FLD_T: factor = 10; break;
|
||||
case FLD_IDC:
|
||||
case FLD_IAC:
|
||||
case FLD_F: factor = 100; break;
|
||||
default: factor = 1000; break;
|
||||
}
|
||||
|
||||
uint8_t *p = &buf[bufPos];
|
||||
|
||||
uint32_t intval = (uint32_t)(val * factor);
|
||||
if(2 == len) {
|
||||
p[0] = (intval >> 8) & 0xff;
|
||||
p[1] = (intval ) & 0xff;
|
||||
}
|
||||
else {
|
||||
p[0] = (intval >> 24) & 0xff;
|
||||
p[1] = (intval >> 16) & 0xff;
|
||||
p[2] = (intval >> 8) & 0xff;
|
||||
p[3] = (intval ) & 0xff;
|
||||
}
|
||||
iv->addValue(iv->getPosByChFld(ch, fld), buf);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue