ramapcsx2 / gbs-control

GNU General Public License v3.0
771 stars 110 forks source link

Redesigned OLED menu. Better UI, easier development. #527

Closed PSHarold closed 5 months ago

PSHarold commented 5 months ago

Main features:

Generate translations for menu items:

  1. Open generate_translations.py and locate menu_items.
  2. Translate all items in the list by adding "key: value" to the dictionaries, where key is the language code (can be any string) and value is the translated string in the target language.
  3. Run python generate_translations.py -font size1@path_to_font1 size2@path_to_font2 ... LANG, where size1, size2, ... are the sizes specified in menu_items. path_to_font1, path_to_font2,... are paths to font files. LANG is the language code used as keys in menu_items For example: python generate_translations.py --font 12@/Users/xxx/Library/Fonts/MesloLGLNerdFontMono-Regular.ttf 16@/Users/xxx/Library/Fonts/MesloLGLNerdFontMono-Regular.ttf will update English strings (en-US is default and can be omitted) python generate_translations.py --font 12@some-font.ttf 16@some-other-chinese-font.ttf zh-CN will translate the strings into Simplified Chinese and use 2 different fonts.

Misc:

Need testing.

PSHarold commented 5 months ago

I do not have a rotary encoder on my gbsc (only buttons). Could someone help me test this?

Metaln00b commented 5 months ago

I have one and could test. But we need more testers.

EDIT: Encoder is working, and my first tests are good. Nice work

PSHarold commented 5 months ago

@nyanpasu64 @rickdgray

rickdgray commented 5 months ago

Just hooked up the rotary encoder a couple hours ago. I'll load it up tomorrow and try it

YoImLee commented 5 months ago

I really appreciate the new font, it's much easier to read. I have been testing for a little while and have found a few things.

Picture ![Screenshot_2024-01-26_12-39-14](https://github.com/ramapcsx2/gbs-control/assets/77938792/9705dcfc-ea1d-4a25-8018-89c9b1f895d8)
Picture ![Screenshot_2024-01-26_12-40-10](https://github.com/ramapcsx2/gbs-control/assets/77938792/11d7dba2-821b-4843-adf1-5381c95ed1df)
nyanpasu64 commented 5 months ago

The error actually says Maxmimum (misspelled),which may help in grepping the code for where it comes from.

rickdgray commented 5 months ago

Hey pulled down your branch and gave it a try.

Man, this is such an improvement to the old UI.

I agree, the new font is better and more readable since it's larger. It does cut off the checkmark now, though.

I'm not really sure what the new menu item is for? OSD Menu? When clicked, I just see a timer and that's it.

IDK if it's just my rotary encoder, but the rotations are not always consistent. Sometimes I turn it and it doesn't move. Sometimes it's delayed. Seems like it maybe it is not reading input while processing a selection change? Like I have to briefly pause between each turn to make it change selection properly. Again, I'm not sure if it's just me. I did buy a pretty cheap encoder and I just have it wired up on breadboard right now.

I also find the reversed movement of the encoding kind of off. I expect the selection to go down if I turn it clockwise. Currently, it goes down if turned counterclockwise.

I haven't tried the issue with many presets, yet.

ramapcsx2 commented 5 months ago

Okay, I think the rotary encoder stuff will be tricky. This seems to be something that needs tuned delays on parsing state changes, to debounce the reads and to try and avoid missing steps. It's not really an UI thing, but it seems it got changed in this commit? Maybe to tune it, have a couple of options exposed for users to try different delay / debounce settings. This way, working values could be reported.. Maybe overkill though :p

Double load requirement of custom presets sounds like a new logic bug.

YoImLee commented 5 months ago

The OSD menu opens a menu on screen that lets you tweak a few settings. My rotary encoder seems to work correctly where clockwise is down and vice versa. There's #define NEW_OLED_MENU_REVERSE_ROTATORY_ENCODER in gbs-control.ino to change the direction if needed.

rickdgray commented 5 months ago

I wonder if perhaps your encoder is wired in reverse? Mine is wired as per this image

Edit: oh sorry; I didn't notice it was not harold responding. Well that's two votes for both directions, then. Which direction should be default?

PSHarold commented 5 months ago

I wonder if perhaps your encoder is wired in reverse? Mine is wired as per this image

I do not have an encoder on my gbsc. That's why there are some problems with the encoder. I will "re-reverse" it in the code to make it behave normally. Also, There's a #define NEW_OLED_MENU_REVERSE_ROTATORY_ENCODER 0 in gbs-control.ino, if at anytime you want to reverse it again, change it to 1.

PSHarold commented 5 months ago

Working on the problems.

rickdgray commented 5 months ago

OK I just loaded up what's in master to compare (sorry, only just got my build in a running state yesterday!).

The direction of the encoder is actually the same. But I do still feel it's backwards and probably should be switched regardless. That's just my opinion; I realize this could be subjective.

I don't actually think this PR introduced a bug with debouncing or buffering the inputs. Master branch also has the same behavior. If you spin the encoder quickly, it skips a lot of inputs. I definitely feel like there's some improvement to be made, but in my opinion, it is out of scope and should be it's own PR.

I see now the on screen display; it is very cool! Very convenient to be able to change on the fly. The scroll bars are bugged currently however. A single shift left or right jumps from 0 to 100. The change still works correctly, so probably just the percent calculation for the OSD.

PSHarold commented 5 months ago

OK I just loaded up what's in master to compare (sorry, only just got my build in a running state yesterday!).

The direction of the encoder is actually the same. But I do still feel it's backwards and probably should be switched regardless. That's just my opinion; I realize this could be subjective.

I don't actually think this PR introduced a bug with debouncing or buffering the inputs. Master branch also has the same behavior. If you spin the encoder quickly, it skips a lot of inputs. I definitely feel like there's some improvement to be made, but in my opinion, it is out of scope and should be it's own PR.

I see now the on screen display; it is very cool! Very convenient to be able to change on the fly. The scroll bars are bugged currently however. A single shift left or right jumps from 0 to 100. The change still works correctly, so probably just the percent calculation for the OSD.

Sorry, haven't pushed yet. I also think it's subjective. Sometimes I feel it's reverserd and the next day I feel it's normal. So
I stopped using the encoder and replaced it with buttons (there are some pins not in use). As for the OSD, only Brightess and Constrast can be adjusted progressively (percent bar). The other settings either don't have upper/lower boundaires or have just 2 values (on/off), so the bars are either full or empty.

YoImLee commented 5 months ago

@rickdgray have you tried changing #define NEW_OLED_MENU_REVERSE_ROTATORY_ENCODER to 1? I think wiring the rotary encoder one way or another depends on the way you interpret the symbol on the schematic and this option makes it a non-issue anyway.

rickdgray commented 5 months ago

As for the OSD, only Brightess and Constrast can be adjusted progressively (percent bar). The other settings either don't have upper/lower boundaires or have just 2 values (on/off), so the bars are either full or empty.

Right, that makes sense.

@rickdgray have you tried changing #define NEW_OLED_MENU_REVERSE_ROTATORY_ENCODER to 1? I think wiring the rotary encoder one way or another depends on the way you interperet the symbol on the schematic and this option makes it a non-issue anyway.

Yeah, I did just now. It felt perfect after that. No big deal either way. I'll probably make a PR for the documentation; I think the direction should be mentioned there.

PSHarold commented 5 months ago

@rickdgray You can now reverse control for menu navigation and OSD navigation separately in OLEDMenuConfig.h via REVERSE_ROTARY_ENCODER_FOR_OLED_MENU and REVERSE_ROTARY_ENCODER_FOR_OSD

@YoImLee

YoImLee commented 5 months ago

Custom presets now load first try! It would be nice if filter settings saved to the presets were loaded in as well. The old menu didn't do this either though, so if it's not possible it's no big deal.

The REVERSE_ROTARY_ENCODER_FOR_OLED_MENU option works as expected. REVERSE_ROTARY_ENCODER_FOR_OSD doesn't seem to work for me however.

Having more than 10 presets no longer causes the "Maximum number of items" error and works properly all the way up to 16. Having more than 16 indeed shows a prompt.

The menu seems quite stable now, I like it.

PSHarold commented 5 months ago

Custom presets now load first try! It would be nice if filter settings saved to the presets were loaded in as well. The old menu didn't do this either though, so if it's not possible it's no big deal.

The REVERSE_ROTARY_ENCODER_FOR_OLED_MENU option works as expected. REVERSE_ROTARY_ENCODER_FOR_OSD doesn't seem to work for me however.

Having more than 10 presets no longer causes the "Maximum number of items" error and works properly all the way up to 16. Having more than 16 indeed shows a prompt.

The menu seems quite stable now, I like it.

I'm glad you like it. I don't understand how saving and loading presets work and hopefully someone can make that happen.

REVERSE_ROTARY_ENCODER_FOR_OSD should now work correctly. (btw did you set both REVERSE_ROTARY_ENCODER_FOR_OLED_MENU and REVERSE_ROTARY_ENCODER_FOR_OSD to 1? In that case the old code just reversed osd nav to normal, kinda like -1*-1=1 because osd nav depended on oled nav)

YoImLee commented 5 months ago

Yeah, I did try all combinations and I don't remember exactly what caused it to not behave as expected. Either way this new code seems to work correctly for me.

rickdgray commented 5 months ago

Awesome work!

rickdgray commented 5 months ago

I just pulled down the latest and everything discussed works correctly. The only things I would mention is that the 2 OSD menus are still disabled, and that in 1080 resolution, the OSD is stretched and doesn't follow the same aspect ratio.

ramapcsx2 commented 5 months ago

All good then? :)

Metaln00b commented 5 months ago

@PSHarold Hey, the scrensaver is nice :D and it could solve #506

rickdgray commented 5 months ago

@ramapcsx2 I vote to merge.

@Metaln00b I agree! This would resolve that ticket too.

lito69 commented 5 months ago

Hello, I would love to have those menus, but I don't know how to do it, can someone please compile a bin for me? Or explanation of how to compile it. I have gbsc retroescaler Thank you

ramapcsx2 commented 5 months ago

Okay, thanks to version control, even if this somehow turns sour, we can revert it later. Going to merge in 1-2 days! :)

lito69 commented 5 months ago

Bien, gracias al control de versiones, incluso si esto de alguna manera se vuelve amargo, podemos revertirlo más tarde. ¡Se fusionará en 1-2 días! :)

Thanks, it would be very fun to see an OSD with basic resolution information and HZ that we are using.

nyanpasu64 commented 5 months ago

Don't have time to review this pull request, but if it works fine in testing I'll let it be merged. (I've decided to stop insisting that I fully understand projects I'm not actively maintaining.)


It would be nice if filter settings saved to the presets were loaded in as well.

I don't understand how saving and loading presets work and hopefully someone can make that happen.

Story time... currently if you load a preset along with its filter settings, your browser first makes a web request to load a preset, and during preset loading your browser makes another request to restore filters.

const loadPreset = () => {
    loadUser("3").then(() => {
        if (GBSStorage.read("customSlotFilters") === true) {
            setTimeout(() => {
                fetch(`/gbs/restore-filters?${+new Date()}`);
            }, 250);
        }
    });
};

Unfortunately, not only does preset loading not finish by the time the browser tells the GBS to restore filters, but worse yet the GBS runs the "/gbs/restore-filters" callback/handler during the middle of talking to hardware using I2C, which I suspect may lead to stack overflows and crashes! This is not easily fixable without replacing the web framework (which requires a substantial code rewrite beyond the energy I can volunteer).


The rest of this post is more brainstorming than related to this PR directly... As a fix to existing code (not introduced in this PR), I very much think that this code should not run from "/gbs/restore-filters", but instead after case '3': // load custom preset (to both avoid sending web requests during I2C, and avoid potential race conditions though I don't see anything obvious). But I again don't know how to only run it if the user enables per-slot filters.

YoImLee commented 5 months ago

Very interesting. I always found it a bit odd how that particular setting was saved in the browser.

rickdgray commented 5 months ago

@lito69 https://ramapcsx2.github.io/gbs-control/Wiki/Software-Setup.html

lito69 commented 5 months ago

@lito69 https://ramapcsx2.github.io/gbs-control/Wiki/Software-Setup.html

Hello, yes, the bin to flash my esp8266 with the files can be compiled, but I don't know how to implement everything they edit here for these mods

ramapcsx2 commented 5 months ago

Sounds like the entire server stuff should be redone, ideally when moving to other hardware (exploit their improvements, such as multi core). This PR though sounds good. Let's hope the server will manage :)

ramapcsx2 commented 5 months ago

Thanks for the work done here everyone! It would be great if you could monitor a bit, see whether people have issues they can't solve :)

lito69 commented 5 months ago

I have found an error: When I select 1289x960 it is not marked in the web interface. The OSD sometimes when you raise or lower the bar goes to extremes, it does not go up percentage wise. The osd cannot select volume or what I think is color. GBSC is wonderful now! Thank you very much, I am happy with these things, if there could be temporarily an osd with basic resolution and hz information that would be wonderful.

https://www.youtube.com/watch?v=EyoqJvYDYd8

PSHarold commented 5 months ago

I have found an error: When I select 1289x960 it is not marked in the web interface. The OSD sometimes when you raise or lower the bar goes to extremes, it does not go up percentage wise. The osd cannot select volume or what I think is color. GBSC is wonderful now! Thank you very much, I am happy with these things, if there could be temporarily an osd with basic resolution and hz information that would be wonderful.

https://youtu.be/EyoqJvYDYd8?si=IfbWwkx-vgS3QJqN

  1. Only Brightess and Constrast can be adjusted progressively (percent bar). Scaling and Moving cannot because I used exisiting code to achieve these two functions and haven't implemented percentage. It requires refactoring some functions. I'll fix it.
  2. Volume and Hue are disabled because there are no corresponding controls in gbsc, I think.
  3. As for WebUI, can someone help confirm and locate the problem?
lito69 commented 5 months ago

Thank you, it's fun for me to try, I put in my previous message a link to YouTube where I try it, I'm proud of the community.

https://www.youtube.com/watch?v=43IozivnS9Y

Is there a possibility of making an osd with basic resolution and hz information? As on the OLED screen but on the TV, a duration of 5s is enough

YoImLee commented 5 months ago

I have found an error: When I select 1289x960 it is not marked in the web interface.

1280x960 will only work with 60Hz. It seems like you're using a 50Hz source in your video, which will only work with 1280x1024. I think this is by design and not a bug.

When using a 50Hz and selecting 1280x960 the GBS will automatically switch to 1280x1024, and vice versa.

Screenshot_2024-01-31_17-33-55

lito69 commented 5 months ago

He encontrado un error: Cuando selecciono 1289x960 no está marcado en la interfaz web.

1280x960 sólo funcionará con 60Hz. Parece que estás usando una fuente de 50 Hz en tu vídeo, que sólo funcionará con 1280x1024. Creo que esto es por diseño y no un error.

Cuando utilice 50 Hz y seleccione 1280 x 960, el GBS cambiará automáticamente a 1280 x 1024 y viceversa.

Captura de pantalla_2024-01-31_17-33-55

ok, perfect

TaHo82 commented 4 months ago

I recently switched to this version. And I've noticed that all my profiles for the 50 Hz consoles only output a "squeezed" picture like 16:9. The resolution is 1280x1024. If I then set the resolution to 1920X1080 everything is back to 4:3 but I lose the Wifi connection to the GBS-C.

Am I the only one who has this problem?

nyanpasu64 commented 4 months ago

Do you get different results here vs. older software versions? Are you applying profiles from the web UI (behavior inadvertently changed in this PR?) or the OLED menu (rewritten)?

TaHo82 commented 4 months ago

In the old version, the aspect ratio was correct at a resolution of 1280x1024. The profiles were created in the old version via the web UI and also worked. It is possible that a value was changed by mistake, but I am not sure what can cause such behavior? I have also tried to do a complete reset and create new profiles. But unfortunately with the same result. I will switch to an old software version when I get the chance and see if it works again.

nyanpasu64 commented 4 months ago

Are you applying profiles from the web UI or the OLED menu?

TaHo82 commented 4 months ago

I have tried both, with the same result.

Metaln00b commented 4 months ago

I have tried both, with the same result.

Can you show us the output of the console? Use the serial console via USB. Maybe then we can see why the connection breaks off and maybe we can also see if something goes wrong when switching.

ramapcsx2 commented 4 months ago

@YoImLee By design, yea. PAL sources have a higher line count than NTSC, so they get a different ideally matching line multiplier. It comes out to "by 1024" for PAL and "by 960" for NTSC. And yea, they're the recommended profiles for each format.

Aleksandr-S12 commented 4 months ago

The new menu looks very good ! But still there is no better full-fledged OSD. I'm sorry, I'm not doing projects on (github), but I made OSD on STV 9426 separately. If someone wants to create such a mod or integrate it into the GBS control project, I can give the source code. This is the old version https://youtu.be/mX-OPXw0_Cs. Here is the new design 2024-02-17777777ttttttttt

Aleksandr-S12 commented 4 months ago

Completed the OSD migration to the new GPS control firmware. Here you can download the source code + instructions https://drive.google.com/file/d/1A3cEvOVxRw7vXp-hBSo_EXhc9TweQ5E0/view?usp=sharing Screenshot 2024-02-22 03-13-07 Screenshot 2024-02-22 03-13-22

nyanpasu64 commented 4 months ago
Aleksandr-S12 commented 4 months ago

Unfortunately, there is no time to learn how to work on github (. I hope that someone will do it for me, so I posted the archive. To control the OSD menu, you only need to connect the STV9426 chip. You can buy STV9426 on Aliexpress