Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuickGLUI and apps #163

Merged
merged 14 commits into from
Dec 30, 2020
Merged

QuickGLUI and apps #163

merged 14 commits into from
Dec 30, 2020

Conversation

anakod
Copy link

@anakod anakod commented Dec 23, 2020

Features

  1. QuickGLUI - high level API for quick clock application development
  2. FX Rates - currency rates monitoring application (you should obtain free api key from currencyconverterapi.com)
  3. IR Remote - new version of IR control application with full remote configuration over Bluetooth: WConfigurator

Goals
Many parts of different apps currently are really very same (web requests and synchronisation, standard app buttons, configuration and so on). Goal of the QuickGLUI library — provide high level abstraction layer which will allow to write new applications very quickly without big knowledge (and easier for the beginners). But in same time it keep flexibility for non-standard cases (user always can overwrite default behavior if needed).

For comparsion, two applications with alsmost same functionality (syncronization, widget support, HTTP request and JSON parsing):

  1. crypto_ticker: 1021 lines of code
  2. fx_rates: 152 lines of code
    (~7 times smaller)

Also, it's much easier to write and understand the code using QuickGLUI abstraction layer. This should allow beginners start clock application development quickly:
https://github.com/anakod/My-TTGO-Watch/blob/quickglue/src/app/fx_rates/fx_rates.cpp#L70
https://github.com/sharandac/My-TTGO-Watch/blob/master/src/app/crypto_ticker/crypto_ticker_main.cpp#L64

@anakod
Copy link
Author

anakod commented Dec 23, 2020

Screenshots:
screenA screenB screenC

@anakod anakod changed the title Quickglue QuickGLUI and apps Dec 23, 2020
@sharandac
Copy link
Owner

Great work! And a heavy update! Is it possible for you to create documentation? Like the following code fragment from blectl.h.
This would make it easier to use, and the help would appear in PlatformIO as you type.

    /**
     * @brief registers a callback function which is called on a corresponding event
     * 
     * @param   event  possible values:     BLECTL_CONNECT,
     *                                      BLECTL_DISCONNECT,
     *                                      BLECTL_STANDBY,
     *                                      BLECTL_ON,
     *                                      BLECTL_OFF,       
     *                                      BLECTL_ACTIVE,    
     *                                      BLECTL_MSG,
     *                                      BLECTL_PIN_AUTH,
     *                                      BLECTL_PAIRING,
     *                                      BLECTL_PAIRING_SUCCESS,
     *                                      BLECTL_PAIRING_ABORT
     * @param   blectl_event_cb     pointer to the callback function
     * @param   id                  pointer to an string
     */
    bool blectl_register_cb( EventBits_t event, CALLBACK_FUNC callback_func, const char *id );

Copy link
Owner

@sharandac sharandac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some files you use ps_mallac, to future versions it would be better to use hardware/alloc.h. It makes easier to change memory allocation method when it is necessary.

#include "hardware/alloc.h"

MALLOC( ... )

@anakod
Copy link
Author

anakod commented Dec 24, 2020

I'm afraid what it will be hard to write full documentation in one moment. Also I want to belive what community may help with that :)
During the development process, I tried to give the methods clear and readable names that are understandable without additional reading of the help. This is especially true for the Widget section - all methods in it are named and accept data types completely equivalent to LVGL methods, so you can freely use the LVGL documentation to work with them. In any case, I will try to document the most specific parts - first of all, this is about Application and SynchronizedApplication functionality.

Regarding ps_mallac - OK. In developer section on my-ttgo-watch.co.uk was said what ps_mallac prefered to use, so I decide use it :) But in same time during development I tried to avoid dynamic memory allocation and used it only where it's really needed. For example, Widgets use ps_mallac only in the case of external event handlers binding.
I will replace ps_mallac with MALLOC and update this P-R.

@datacute
Copy link
Collaborator

I've started reviewing the changes too

@anakod
Copy link
Author

anakod commented Dec 25, 2020

Documentation added

@datacute
Copy link
Collaborator

I can't get the IR Controller configured. It behaves ok with no configuration though, just showing the exit button.
WConfigurator either stays spinning, or reports an error requesting a reload, or the 1 time I've managed to get it to show an Add button, nothing happened when the button was clicked.


#include "lvgl/lvgl.h"
#include "../widgets/widget.h"
#include "../widgets/widget.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"../widgets/widget.h" is included twice

return true;
}

String JsonRequest::fromatCompletedAt(const char* format)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "fromat" should be "format"

@sharandac sharandac merged commit e346dbd into sharandac:experimental Dec 30, 2020
@anakod
Copy link
Author

anakod commented Dec 31, 2020

@datacute Thank you for feedback about issues in code, I'm fixing it now.

I can't get the IR Controller configured. It behaves ok with no configuration though, just showing the exit button.

That's Ok because you have not configured buttons yet. There isn't any added by default buttons currently . So you should add them depends on your devices. May be I should add something by default to make it more clear?

WConfigurator either stays spinning, or reports an error requesting a reload

It's definitely looks like a bug. In my case, problems do not happen often, but they do happen sometimes (much better than WiFi FileManager in my case but still not very good). Reload help always in such cases. Mostly I'm face issues when workig with long RAW IR codes. I'm planning to review bluetooth stack implementation and may be will find and fix issues reason than.

an Add button, nothing happened when the button was clicked.

You should enter button name in the left text field before click Add button. May be it isn't clear - I think I should update WConfigurator app also, what do you think?

@datacute
Copy link
Collaborator

Thanks for the code. I committed fixes for the minor issues.
I created a couple of json files, 1 to replace the previous setup, and then another to try and get my sony bravia tv to turn on. My cell phone shows the IR flashing, but my TV remains off.

@datacute
Copy link
Collaborator

datacute commented Jan 1, 2021

I'm wondering whether you can enhance the ftp server and json app configuration capabilities so that when a new config file is ftp'd over, I don't need to reset the watch for the app to pick up the changes?

@datacute
Copy link
Collaborator

datacute commented Jan 1, 2021

I've succeeded in turning on my Sony TV, but need to be able to specify the number of bits to send...
My Sony TV needs
irsend.sendSony(config->code, 12);
My Sony BluRay player needs:
irsend.sendSony(config->code, 15);

@anakod
Copy link
Author

anakod commented Jan 1, 2021

I'm wondering whether you can enhance the ftp server and json app configuration capabilities so that when a new config file is ftp'd over, I don't need to reset the watch for the app to pick up the changes?

I think it isn't correct direction, instead of that we should resolve problems with WConfivurator connection or add functionality to my-ttgo-watch.co.uk (or both). I'm afraid what your issue anyway related to clock Bluetooth code, not external app functionality.

@anakod
Copy link
Author

anakod commented Jan 1, 2021

I've succeeded in turning on my Sony TV, but need to be able to specify the number of bits to send...
My Sony TV needs
irsend.sendSony(config->code, 12);
My Sony BluRay player needs:
irsend.sendSony(config->code, 15);

Very interesting. Can we calculate required amount of bits automatically somehow (from the IR code)? If not we should add additional parameter for Sony devices, I think.

@drunkscientist
Copy link

so apologies in advance if this is the wrong place for this, but im looking for a little more clarity on how to use quickGLUI. im working on an app to connect to a 3d printer (#164 ), and since it is similar to the others, i simply copied your fx_rates app and renamed everything. but im not sure i understand how its actually working. i see how the variables get displayed to the widget, but i dont understand how they get set. here is what i have/where things diverge, maybe someone can help me understand how the fetch__data bit works. or just more directly how to open up a telnet/websocket/raw connection of whatever sort, on 192.168.1.215, port 8888, and send 4 characters, the response should just be displayed directly. im sorry again if this is a basic question, all the examples ive found are either for the esp to be the server, or sending data to a server for storage/logging.

@anakod
Copy link
Author

anakod commented Mar 5, 2021

QuickGLUI can't provide solutions for telnet/websocket/raw connection for now. Currently only HTTP JSON request was implemented and also it has just very basic functionality. Main benefit of using QuickGLUI - significant simplify of the application interface and app settings page development. So as I understood your task, I think here it can be helpful.

From my opinion, to implement 3d printer control application you will need to find and modify printer communication code, after that you can integrate it to the app without issues and relatively quickly.

@drunkscientist
Copy link

ahh ok, i think i understand now. will play with it, i dont think ill need to modify anything on the printer end, if i can implement something basic that will execute inside that same fetch_x_data function (and it might have json support im not sure still). connect->send command->store response to be displayed later. at the moment i dont think this is going to be so much a 'control' program so much as a monitor, since there is a webUI that can be used from phone/tablet etc, but users could add additional commands i suppose.

on a slightly unrelated note (or rather back to the previous topic): what is the intended method for acquiring IR codes? i used a random receiver module and an arduino nano with an example sketch IRrecieverDemo to capture the codes from my emerson remote, which gave me hex values like 0xDF20E084. after putting them into wconfigurator (set nec, hex, etc) they dont match what was entered, and the nano reads them with 'parity error' or something, im assuming i have something formatted wrong. dunno if there was a particular receiver sketch that should be used but i figgured id ask since wconfigurator is... well for me its unreliable. most of the time i click and it just spins, when i do go through and make changes and click save they are usually lost

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

Successfully merging this pull request may close these issues.

4 participants