Skip to content

Conversation

@kohrar
Copy link
Contributor

@kohrar kohrar commented May 22, 2021

Hello everyone!

I hope you are all doing well. I recently wanted to rebuild OpenDPS for my devices but had some difficulty getting all my separate PRs to work in a satisfactory manner. I spent some time over the past couple days getting what I had working previously on the latest master branch as well as further refining the settings screen and some UI rendering to reduce visual glitchiness when changing screens.

Due to the fact that my previous PRs were never merged after sitting for a very long time and the dependencies between some of my desired changes, I've opted to merge my PRs into one instead. Hopefully those that are interested in trying out my DPS mode will have an easier time by being able to just merge one PR.

Features

DPS Mode (based on #166)

  • Brings a similar interface to original firmware
  • Constant Current (CC) and Constant Voltage (CV) mode icons
  • Set and recall M1/M2 preset values for voltage, current, power output limit, and timer (hold M1 or M2 to recall, hold SET + M1 or M2 to set)
  • Additional features in the 3rd line can be set by pressing and turning the rotary. These features include:
    • Max power output limit (Over Power Protection)
    • A timer (showing power-on duration or as a countdown timer)
    • Watt-hour meter
      image

Settings (based on #184)

In the settings screen, you may adjust:

  • the brightness
  • the update speed (for the DPS Mode screen)
  • calibration values for ADC/DAC (negative values now supported!)
  • reset all settings to default values
    image
    Popup messages when settings are saved or reset. Eg:
    image

There are other changes in this PR that may require additional review by kanflo.

  • Changes to uui such that not all UI elements will be forced redrawn
  • Changes to the default font, from Ubuntu to NerdFont for legibility
  • Makefile defaults to CC/CV screens off
  • Modification of uui_number.c to support negative numbers, but this will only for small fonts
  • Addition of uui_time to show time
  • Additional events (required for rotary push & turn combo in the DPS mode screen)

I have tested this PR with most features enabled with the exception of serial/wifi connectivity. Everything appears as it should and seems to function OK. For my own purposes, I have been using is compiled with most features disabled:

make -C opendps flash -j 9 MODEL=DPS5005 INVERT_ENABLE=0 CC_ENABLE=0 CL_ENABLE=0 CV_ENABLE=0 POWER_COLORED=1 POWER_OFF_VISIBLE=1 THERMAL_LOCKOUT=0 SETTINGS_ENABLE=1 FUNCGEN_ENABLE=0 WDOG=1

Feedback is welcomed as always. Please feel free to cherry pick the desired changes to merge into this repo as I'm aware not all the changes here might be desirable to everyone.

Maximum power can be defined and a warning icon will be displayed if
output power exceeds 80%. Power will cut if it exceeds 100% and
a flashing icon will display. Reset by pressing power button once.
While the deactivate callback clears the tft display, because of uui.c's
way of changing screens, another call to enable(false) is called. Any
draws in enable() will cause artifacts on the next screen. All draws
should be done inside the tick callback instead.
fixed the rot m1/m2 event
added 3rd row to display to test
Third item will not change if in select mode
Screen cannot change is locked if power is on to prevent inadvertant data/state loss
Colon rendering should be less glitchy
kohrar added 12 commits October 16, 2019 19:00
This should only be included if the CV option is enabled.
Use the settings screen to adjust the brightness instead
The UI was excessively redrawn when screens change with the call to
uui_refresh. This causes UI elements to flicker. Instead, each screen
will need to refresh only what is necessary on activation

The settings screen no longer flicker when moving through pages as only
the table portion is blanked with a tft_fill call rather than tft_clear.
@kanflo
Copy link
Owner

kanflo commented May 22, 2021

That is one impressive PR. I will have a look at and make sure you did not spend all that time for nothing ;)

kohrar added 6 commits May 23, 2021 06:40
Removed the lock screen option which had no effect
Configuration reset triggered through the reset option rather than the
key combination which is prone to accidental triggering
Popup message will show when settings are saved or reset
A bunch of events were triggeringg past_save. This change will only
trigger a write when power is turned on or when presets are saved to
reduce flash wear.
V/A buttons focuses voltage/current directly.
Preset bars are set on screen activation if values match
Boolean values rendered by uui_number no longer show numeric values
This issue resulted in recalls failing after a reset.
@Conor-Burns
Copy link

Hi, this is awesome!
I have a slight issue with the presets not working. Used your make command and when setting a voltage+current and pressing set+m1/m2 it doesn't save it and skips back to m1 which is set to 0V 0A. Also long-pressing m2 goes to m1 0 0
Also when shutting down it forgets the last voltage - is it supposed to do that?

Many thanks
Conor

@kohrar
Copy link
Contributor Author

kohrar commented Jun 4, 2021

Hi Conor,

I noticed the presets weren't working with my initial PR. The problem was the past data was saving with incorrect IDs and should have been fixed with commit d52b0f2. Did you test with that commit in place? If so, I'll try to replicate it on my end, though I haven't had issues with presets since that commit.

The screen should be saving the voltage+current values during the event_button_enable event. This means the values should be written to when the on/off button is pressed. It does not write the values to flash as the values are changed in order to reduce writes to flash, but perhaps it's something that can be added as a setting option later. Does your DPS 'forget' its voltage/current setting if you hit the on/off button before disconnecting power?

Thanks for the feedback.

Cheers

If insufficient voltage is provided for the set voltage, a warning bar
will be displayed next to the voltage value. This will override the
constant voltage / constant current mode as it stops functioning
properly in this state.
@Conor-Burns
Copy link

Hi thanks for the fast reply!
I just wiped the repo and pulled it to make sure and it still does not work - the preset and the saving of values on button press.
Anything I have to watch out for when flashing?

@kohrar
Copy link
Contributor Author

kohrar commented Jun 8, 2021

Just to confirm the behavior you're experiencing, Conor: After setting a voltage+current value to something non-zero, when you hit set+m1 or set+m2, the values reset back to 0 with the m1 bar displayed?

There isn't anything to building/flashing and I doubt it's something that you're doing incorrectly. I'll try replicating your issue after erasing the flash again. I had it glitch out with similar behavior as you described during development and it's possible it's working for me because I had presets saved previously.

Also, I just noticed the automated build failed from a commit I made last weekend which pushed the program size over the available flash size. I'm sure there's lots of places to optimize which I'll do when I get some free time.

@Conor-Burns
Copy link

Yes this exactly what I experienced.
Would you mind sending me a bin you compiled to exclude errors on my side?

Possibly when nothing is initialized, past read will fail which causes
the logic to not write the new value. I confirmed this behavior by
erasing the flash and then attempting to save the last power setting
which failed.
@kohrar
Copy link
Contributor Author

kohrar commented Jun 9, 2021

I was able to replicate some of the mentioned issues after erasing the flash and then re-flashing again.

Could you please try again with opendps_DPS5005.zip or build from my latest commit on this PR. You can also clear the flash before reflashing in case that's an issue. Just remember to also re-flash the bootloader.

# openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg &
# telnet localhost 4444
> halt
> stm32f1x mass_erase 0

Cheers.

@Conor-Burns
Copy link

Sorry for the late reply, saving the voltage and current after power off works now. when pressing m2 (or m1) + set it just switches to m1 or m2 respectively without saving as a preset.

@mikerocklewitz
Copy link

Can someone build this for dps3005 for me pretty please? I dont have a build env setup for this at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants