-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Proposal to improve /DG implementation #459
Conversation
improved /DG implementation
got rid of gaps in plot lines (which were due to hh:mm differing within param sets)
got rid of gaps in plot lines (which were due to hh:mm differing within param sets)
removed tab in last edit
removed tab in source code
With some trickery, I've now fixed the line gap issue mentioned above - at the expense of an additional 16 Bytes in the BSB-LAN sketch binary. :) What is the best way to offer the improved version for inclusion in BSB-LAN? Closing this pull request and creating a new one? |
Thanks! This looks good so I think I'll merge it, but what do you mean with "What is the best way to offer the improved version for inclusion in BSB-LAN? Closing this pull request and creating a new one?" I would just merge this PR, so why the need for a new one? |
When I originally created this pull request, the line gap problem still existed. I've since fixed it in my BSB_LAN fork. Will that fix also be included when you merge, or will I have to create a new/additional pull request? Btw, I've also figured out how to resolve the invisible favicon on the /DG page. That fix will cost an additional 4 bytes for the sketch binary. I'll include it in my fork now... |
fixed invisible favicon at the top of the /DG page
synchronized with ../html_strings.h (although not really required here)
Well, if you push it here, it will be included. Looking at "Files changed" above, that seems to be the case, but please double-check. Once you're done let me know an I'll merge. |
removed obsolete code (saves 29 Bytes in sketch binary)
code synchronized with ../html_strings.h
Commits ahead is now at 10: I've replaced some code that has become obsolete with my line gap fix, for a sketch binary size reduction of 29 Bytes. |
cosmetics (src=https synced, decided to use the shorter http)
synced with ../html_strings.h
replaced ";}" with "}" in single-line "{...}" - doesn't affect readability/maintainability, but saves a few bytes in the sketch binary
sync'ed with ../html_strings.h
Hi! I want to insert two words: i propose to save D3 library too and add preprocessor directives.
|
Oops, lost one important ';' some commits ago.
sync'd with ../html_strings.h (although not important here)
While I personally don't see any advantages in the D3-only implementation, I don't think giving the users a choice between it and my D3+C3 proposal would hurt. :) |
Using https instead of http for remote javascript libraries, to avoid redirect and allow browser caching
sync'd with ../html_strings.h
Btw, should you decide to keep the D3-only implementation (as an alternative to D3+C3 or as the only option): |
...and a considerable amount of bytes can be shaved off the sketch binary with the D3-only implementation by keeping whitespace and comments out of the string containing the html/javascript code. For a start, running the following on the D3-only implementation section in html_strings.h saves 1682 bytes: More can be saved by manually going through the implementation (or by using a more sophisticated automation). The price for this sketch binary code saving is reduced legibility in the html received by the BSB-LAN client, but who reads that anyway? |
You right but if we want to improve code it would be pain for our brains :) |
No, it wouldn't. Just read the Code in html_strings.h, which can contain comments and indentation, as in my proposal here! |
In case you haven't tried it: Passing the D3-only implementation for /DG through the perl one-liner above creates the text attached here. In my personal opinion, readability is not affected by this 1682 bytes code reduction. In fact, I would consider an additional removal of most of the \n at/as the line endings in the string pieces an improvement in readability. However, it seems that a few of them are actually required to have the javascript code execute properly. I haven't bothered to look which ones those are. Also, there's a few multi-line comments which could be moved out of the html code into the surrounding C code of html_strings.h itself, ... |
Thanks for the suggestion regarding stripping whitespace etc. from the HTML output. I think the code output in your attachement is readable fine, so please push a properly working version of this into this PR. |
I had already tested the *.txt posted above to work properly. :) Just to make sure that there's no misunderstanding: This is also what I did in my D3+C3 implementation originally discussed here, besides the following sketch binary reducing measures:
I've intentionally kept two unnecessary semicolons in my code - in places where I consider them supportive of readability/maintainability. 1-3 are also used in the used javascript libraries' "min" versions, btw - by their authors/distributors. This is what reduces transmission time for them, but makes them hard to read. With the length and complexity of the original D3-only implementation for BSB-LAN's /DG feature, I suggest to refrain from using measures 1+3 on it. |
Yes, code-readability in the output will be affected, that's clear. |
re-introduced the original D3-only implementation for log file plotting (/DB) as an option (used unless #ifdef USE_ADVANCED_PLOT_LOG_FILE) ... and reduced its BSB-LAN binary code footprint by 2256 bytes through moving whitespace and comments out of the html strings ... and also fixed the invisible favicon in the D3-only version more sketch binary code savings achieved by: - removing trailing zeroes (after the decimal point) in the svg code for the favicon => -52 bytes - removing obviously unnecessary \n characters in the older html strings => -48 bytes
introduced "#define USE_ADVANCED_PLOT_LOG_FILE", which can be disabled to keep the older D3-only implementation for the /DG functionality
Done:
|
BTW, the ESP32's OTA update functionality is VERY handy in trying out implementation changes. :) |
Great, thanks a lot! Will merge now... |
Ok, it could either be this: |
The only thing I can think of that I cannot rule out easily is that I might have removed one or the other \n too many in the non-/DG sections of html_strings.h. If that's the case, please accept my apologies for not having tested enough! Feel free to use the attached file instead of the current html_strings.h, which does revert this one particular change I made. This should increase the sketch binary by 48 bytes again, but otherwise shouldn't affect anything. (No, I have not removed anything concerning by BSB-LAN fork.) |
No, it's not an error in the code, it's an error in the merging process. But since I just now pushed a change in the changelog and now the error is no longer coming up, it's probably just been a hiccup somewhere down the line. |
/CI is config saving, right? |
...and config saving still does work on my system - with the latest files from my pull request / fork. (Just tested with disabling logging in /C.) |
If this is an ongoing issue, please open up a seperate issue/bugreport for that, otherwise it'll get lost here. |
No, that was just a single incident with my system, probably caused by a temporary coding error in my BSBmonCR project's customisation of BSB-LAN that had caused a buffer overflow. |
When should chapter 4 in the BSB-LAN user manual adapted? Now? |
No worries, @1coderookie will take care of it once he has time for it. |
Sorry for misunderstanding: I meant to give users option to choose between C3 and D3, but not using both libraries at the same time. |
C3 is built on top of D3, it does not work without it. |
Oh, clear, thanks. |
Changed /DG data plot implementation to use C3.js on top of D3.js (both under MIT license):
Pros:
Cons:
Remaining issues (already existing in current D3-only implementation):
Tests:
Bonus: