Skip to content

Commit

Permalink
Fix offset configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuba authored and Kuba committed Apr 23, 2019
1 parent f4f42f4 commit eca29ee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
28 changes: 22 additions & 6 deletions esp_fy6800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,36 @@ void setCh2Phase(uint32_t phase)
fy6800_write(command, 10);
}

void setCh1Offset(uint32_t offset)
void setCh1Offset(int32_t offset)
{
char command[] = "WMO00.000\n";
snprintf(command, 11, "WMO%02d.%03u\n", offset/1000, offset%1000);
gDeviceState.ch1Offset = offset;
fy6800_write(command, 10);
if(offset>=0)
{
snprintf(command, 11, "WMO%02u.%03u\n", offset/1000, offset%1000);
fy6800_write(command, 10);
}
else
{
snprintf(command, 12, "WMO-%02u.%03u\n", -offset/1000, -offset%1000);
fy6800_write(command, 11);
}
}

void setCh2Offset(uint32_t offset)
void setCh2Offset(int32_t offset)
{
char command[] = "WFO00.000\n";
snprintf(command, 11, "WFO%02d.%03u\n", offset/1000, offset%1000);
gDeviceState.ch2Offset = offset;
fy6800_write(command, 10);
if(offset>=0)
{
snprintf(command, 11, "WFO%02u.%03u\n", offset/1000, offset%1000);
fy6800_write(command, 10);
}
else
{
snprintf(command, 12, "WFO-%02u.%03u\n", -offset/1000, -offset%1000);
fy6800_write(command, 11);
}
}

void initDevice(void)
Expand Down
4 changes: 2 additions & 2 deletions esp_fy6800.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ void setCh1Phase(uint32_t phase);
void setCh2Phase(uint32_t phase);

/* Offset is in mV: 12.345V = 12345 */
void setCh1Offset(uint32_t offset);
void setCh2Offset(uint32_t offset);
void setCh1Offset(int32_t offset);
void setCh2Offset(int32_t offset);

/* Can be used to set some default parameters */
void initDevice(void);
Expand Down

0 comments on commit eca29ee

Please sign in to comment.