Commit Graph

101 Commits

Author SHA1 Message Date
Guðni Már Gilbert 63775dfabb PFW-1504 fix conflicting UI issues
Proposal to fix some of the issues with the initial implementation
it is safer to use the status line code to print the message so
there aren't any conflicts in the LCD cursor position.

Allow inserting a byte into any position in the LCD status message

Also, add a variable to control from which index in the array
should the message start printing. This is very useful for progress
bars and messages which continually update. I think we can save some
memory by applying this to Mesh Bed Leveling later.

Change in memory:
Flash: +106 bytes
SRAM: +1 byte
2023-07-27 16:44:34 +00:00
Guðni Már Gilbert 6623d45af9 optimisation: Tighter LCD timing
Author: leptun

Change in memory:
Flash: -14 bytes
SRAM: 0 bytes
2023-07-25 15:02:49 +00:00
Alex Voinea a354aad762
Merge pull request #4167 from leptun/lcd_encoder_improvements
Lcd encoder improvements
2023-04-24 15:58:54 +02:00
Alex Voinea c339711025
Make the encrot table balanced
It won't change much. It is not possible to determine in which direction the encoder spun when two steps are made, so just use + or - 2.
2023-04-24 11:56:25 +02:00
Alex Voinea 32e68c33b4
lcd encoder: use lookup table
Also handle the scenario where the encoder moves two steps in a single lcd_buttons_update cycle.

Flash: -46B
SRAM: 0B
2023-04-24 11:56:13 +02:00
Alex Voinea ea101f49d4
`lcd_buttons` is actually `lcd_click_trigger`
Flash: -4B
SRAM: 0B
2023-04-24 11:56:04 +02:00
Alex Voinea dd16cf4525
Remove Binary.h include 2023-04-24 11:52:25 +02:00
Alex Voinea 17e085040c
Add missing line to custom character
Shouldn't make a difference since the array is already defined as 8B long, but I just found it weird and surprising when I noticed only 7 lines were defined
2023-04-24 10:44:48 +02:00
Alex Voinea 548ed0eb31
Convert <binary.h> to native binary literals 2023-04-24 10:42:09 +02:00
Alex Voinea 5778e39687
Resync `lcd_encoder_diff` when clicking
Flash: +4B
SRAM: 0B
2023-04-23 10:07:52 +02:00
Alex Voinea c037e6dfba
Use atomic block for accessing lcd_encoder_diff
There was still the possibility of lcd_encoder_diff being updated from the ISR while the new enc_diff was being computed.

Flash: +8B
SRAM: 0B
2023-04-23 09:58:56 +02:00
Alex Voinea 1f181a949a
Fix `lcd_encoder_diff` getting out of sync with the knob hard steps
Flash: +18B
SRAM: 0B
2023-04-23 09:48:09 +02:00
Guðni Már Gilbert ccabf1fa31 Remove random //-// comments 2023-04-22 13:39:08 +00:00
Guðni Már Gilbert 18c389543b Fix lcd_update() FW crashes
Change in memory:
Flash: +10 bytes
SRAM: 0 bytes
2023-04-19 15:41:36 +00:00
D.R.racer dfe6ea6470 Fixup after rebase 2023-04-06 07:44:16 +02:00
Guðni Már Gilbert 062ea1cf25 optimisation: make lcd_encoder two bytes (int16_t)
lcd_encoder was int32_t (4 bytes) because of the menu code
when editing through the menus, the menus only accept
int16_t so it doesnt make sense to use int32_t.

Change in memory:
Flash: -892 bytes
SRAM: -2 bytes
2023-04-06 07:44:16 +02:00
Guðni Már Gilbert ffc34edf4c Pull in changes from PR 4080
Additionally make lcd_encoder_bits static
since it's not used outside the ISR context
2023-04-05 10:30:59 +02:00
Guðni Már Gilbert a7e9ccfb57 Major refactoring
Fixes all the issues I've found so far.

Roughly 60B of flash saved. Need to double check that later.
2023-04-05 10:30:59 +02:00
Guðni Már Gilbert d89e6de040 Update lcd_encoder in lcd_update
This fixes the spurious feedback when rotating the knob
because lcd_update is called much often than the interval
at which the lcd rendering is updated

Change in memory
Flash: -88 bytes
SRAM: -9 bytes
2023-04-05 10:30:59 +02:00
Guðni Már Gilbert 0cac7612db optimisation: Always make sound when knob is clicked or rotated
This commit adds the ability for firmware to make sounds when the
knob is clicked or rotated, when LCD updates are disabled.

The improvement here is the sound is being made with one line of code
whether or not LCD updates are enabled or disabled.

Change in memory:
Flash: -24 bytes
SRAM: 0 bytes
2023-04-05 10:30:59 +02:00
Guðni Már Gilbert 8a926fad10 backlight: set rotation flag when certain amount of pulses are detected
We don't want to trigger a backlight wakeup randomly, for example
due to background noise.
2023-02-20 18:26:43 +00:00
Guðni Már Gilbert db878c9996 backlight: always allow backlight to dim/wake
This commit adds the ability for the firmware to dim and wake the
backlight when LCD updates are disabled. Such as in the MMU error screen
or when rendering full screen messages which typically
disable the LCD updates to prevent the status screen from rendering.

Fixes #2777

Change in memory:
Flash: -26 bytes
SRAM: +1 byte
2023-02-18 17:08:35 +00:00
Guðni Már Gilbert da63d73585 optimisation: don't print floats with lcd_print()
Change in memory:
Flash: -442 bytes
SRAM: 0 bytes
2023-01-25 18:21:22 +00:00
Guðni Már Gilbert a5f7f1d735 optimisation: change index from uint32_t to uint8_t
Change in memory:
Flash: -152 bytes
SRAM: 0 bytes
2023-01-25 18:21:22 +00:00
Guðni Már Gilbert d83c0f6c40 Fix an issue with indexing PROGMEM pointer
Using array index 'pointer[index]' doesn't work properly.
Instead using "pointer + index" works fine.

No change in memory footprint
2023-01-16 12:36:57 +01:00
Guðni Már Gilbert 9416310f7e optimisation: move row_offsets into PROGMEM
Change in memory:
Flash: -42 bytes
SRAM: -4 bytes
2023-01-16 12:36:57 +01:00
Guðni Már Gilbert eeb5f3d50c optimisation: refactor menu_draw_P()
Add a way to only change the LCD column

Change in memory:
Flash: -90 bytes
SRAM: 0 bytes
2023-01-16 12:36:57 +01:00
Guðni Már Gilbert 730bb3708e Fix an issue with menu_draw_item_puts_P
Change in memory:
Flash: +16 bytes
SRAM: 0 bytes
2023-01-16 12:36:57 +01:00
Guðni Már Gilbert cc08b938b7 Optimisations: implement lcd_print_pad_P()
Used lcd_print_pad_P is some obvious places. We can probably use
this function in more places to further save flash memory

Change in memory:
Flash: -268 bytes
SRAM: 0 bytes
2023-01-16 12:36:57 +01:00
Guðni Már Gilbert 184e19dd60 further optimise lcdui_print_status_line
We can use lcd_print_pad to determine
whether the end of the file name was reached

lcd_print_pad now returns the last character pointed to.
If the end of the string was reached, it will be the null delimeter which
evaluates to "false" in an if statment (same as NULL).
Else "true" means the end of the string was not reached.

Change in memory:
Flash: -42 bytes
SRAM: 0 bytes
2022-11-13 09:29:37 +01:00
Yuri D'Elia 709d07310a lcd_print_pad: do not overflow len when truncating the string 2022-09-26 11:26:10 +02:00
Yuri D'Elia 80c06bda55 Improve warning behavior during thermal anomaly
The current code forces any warning to return the user to the status
screen in order to show the message.

Thermal anomaly warnings can repeat at very short intervals, making menu
navigation (to pause/tune the print) impossible.

We now check if the message to be displayed is the same and only force a
kickback for new messages.

This partially reverts https://github.com/prusa3d/Prusa-Firmware/pull/3600
since we need the string to be null terminated for ease of comparison.

We pad the status line at display time instead using the new
lcd_print_pad() function which achieves the same effect.
2022-09-22 16:12:35 +02:00
Guðni Már Gilbert f6fd91a235 Optimise lcd_status_screen
Saves 20 bytes of flash
2022-07-27 11:14:18 +00:00
Alex Voinea 3c579bf738 Fix fullscreen message lcd_update handling 2022-07-15 15:45:34 +03:00
Alex Voinea 42b91a83cd Merge branch 'MK3' into MK3_3.12_Optimizations 2022-02-10 10:36:31 +01:00
Alex Voinea 1342db3532
Merge pull request #3257 from gudnimg/lcd-optimisation-gudni
Remove redundant operations on LCD CGRAM
2022-02-09 08:09:48 +01:00
Guðni Már Gilbert 800f44509d Change row_offsets[] to uint8_t
Saves 10 bytes of flash, and 4 bytes of SRAM
2022-01-30 11:39:24 +00:00
Guðni Már Gilbert cf8a16baa1 Remove one call to lcd_timeoutToStatus.start
Saves 8 bytes of Flash memory

This call is redundant and when moving between menus
it gets called multiple times which results in waste
of clock cycles.

lcd_timeoutToStatus.start() is called from menu_lcd_lcdupdate_func()
which is enough.
2021-08-21 14:34:02 +00:00
Guðni Már Gilbert b716c208d7 Various optimisation to change int to uint8_t
This commit saves 174 bytes of flash memory
2021-08-03 22:42:01 +00:00
Guðni Már Gilbert da2c802440 Add two defines and use LCD_STR_DEGREE with consistency
This saves 12 bytes of flash and 2 bytes of SRAM
2021-08-01 11:10:03 +00:00
Guðni Már Gilbert 6afc87d3c8 Reduce unnecessary LCD CGRAM writes 2021-07-30 23:53:57 +00:00
Yuri D'Elia 72b8f0d1e6 Add some warnings in lcd_buttons_update 2021-06-19 13:46:10 +02:00
Yuri D'Elia 06d91ddcee Handle Long-Press in the main loop
The longpress function is currently called within the temperature ISR,
which is bogus. Calling the longpress function at the wrong moment
can corrupt the menu buffers.

Move the call to the main loop by changing the logic slightly:

- still sample the lcd buttons inside the temperature ISR, which keeps
  scrollong/pressing responsive, but...
- set a flag to indicate that longpress has been triggered instead of
  calling the function directly
- call the function on the next manage_inactivity run

Combined with #3180 this removes _most_ unsafe operations out of the ISR
which can happen during a normal run (max/mintemp warnings are still an
exception).
2021-06-17 20:07:01 +02:00
Alex Voinea 4c977cc335 Merge branch 'MK3' into MK3_NEW_SD_COMPILATION 2021-02-03 18:28:18 +02:00
D.R.racer 783e4bbaf9 Add lcd_putc_at (code down >150B), refactor lcd_selftest_screen_step
(RAM down 10B)
2021-01-25 14:58:57 +01:00
Alex Voinea f35e553373
Code cleanup 2020-03-04 20:33:43 +02:00
Alex Voinea 7028583e9b
Merge branch 'MK3_ShellSort' into MK3_NEW_SD_COMPILATION 2020-01-08 16:27:31 +02:00
Alex Voinea 960f4a88ed
Status bar, lcd optimization, compile warning fix 2019-11-26 13:36:28 +02:00
Alex Voinea b3a587f5a4 SD first attempt. Broken 2019-11-20 20:25:51 +02:00
DRracer f3c3526aa5 fix the knob long-press causing hang in modal dialogs 2019-10-01 17:13:36 +02:00