multi_converter_mode_display.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <input/input.h>
  3. #include <gui/gui.h>
  4. #include "multi_converter_definitions.h"
  5. #include "multi_converter_units.h"
  6. //
  7. // performs a unit conversion from origin to source buffers, if there's any error, overflow or
  8. // non-compatible format (which shouldn't happen, but just in case) abort conversion and outputs
  9. // some "?" strings on the buffer or something similar
  10. //
  11. void multi_converter_mode_display_convert(MultiConverterState* const multi_converter_state);
  12. //
  13. // draw the main DISPLAY view with the current multi_converter_state values
  14. //
  15. void multi_converter_mode_display_draw(
  16. Canvas* const canvas,
  17. const MultiConverterState* multi_converter_state);
  18. //
  19. // keyboard navigation on DISPLAY mode (NAVIGATION only, no BACK nor OK - InputKey guaranteed to be left/right/up/down)
  20. //
  21. void multi_converter_mode_display_navigation(
  22. InputKey key,
  23. MultiConverterState* const multi_converter_state);
  24. //
  25. // reset the DISPLAY mode with the current units, cleaning the buffers and different flags;
  26. // call this when exiting the SELECT mode / changing the units
  27. //
  28. void multi_converter_mode_display_reset(MultiConverterState* const multi_converter_state);
  29. //
  30. // toggle the negative flag on current selected buffer ONLY if the unit allows negative numbers
  31. // (adding negative number may crop the last char on the buffer; it cannot be recovered)
  32. //
  33. void multi_converter_mode_display_toggle_negative(MultiConverterState* const multi_converter_state);
  34. //
  35. // add a comma/dot/decimal separator/whatever on current selected buffer ONLY if the unit allows it
  36. // (only ONE comma allowed, not in the beginning nor end)
  37. //
  38. void multi_converter_mode_display_add_comma(MultiConverterState* const multi_converter_state);
  39. //
  40. // add a regular number to the buffer if it's <= the max_number_keys from the unit (not necessary
  41. // since the draw and navigation functions won't allow a trigger for an invalid number, but still
  42. // to keep the "checks" policy on each "add key" function...)
  43. //
  44. void multi_converter_mode_display_add_number(MultiConverterState* const multi_converter_state);
  45. //
  46. // handle the OK action when selecting a specific key on the keyboard (add a number, a symbol, change mode...)
  47. // returns a ModeTrigger enum value: may or may not let to a mode change on the main loop (WON'T change the mode here)
  48. //
  49. MultiConverterModeTrigger multi_converter_mode_display_ok(
  50. uint8_t long_press,
  51. MultiConverterState* const multi_converter_state);