Click here to Skip to main content
16,016,580 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Looking at the very topmost line ... Pin
Daniel Pfeffer5-Jun-24 8:29
professionalDaniel Pfeffer5-Jun-24 8:29 
GeneralRe: Looking at the very topmost line ... Pin
jochance6-Jun-24 6:31
jochance6-Jun-24 6:31 
GeneralRe: Looking at the very topmost line ... Pin
Richard Andrew x6416-Jun-24 8:12
professionalRichard Andrew x6416-Jun-24 8:12 
GeneralBlessed endian mismatches collide with progress Pin
honey the codewitch1-Jun-24 7:30
mvahoney the codewitch1-Jun-24 7:30 
Almost all embedded MCUs are little endian.
Almost all display controllers that can connect to them are big endian.

My graphics library builds pixels in big endian order on little endian machines as a consequence. It's just more efficient.

LVGL is another embedded graphics library - one I contribute to - and they removed a feature on version 9+ where you could set it to swap the bytes on a 16 bit color value. This is to compensate for the endian issues.

Not swapping during the draw operation means you need to scan and rearrange the transfer buffer before you send it to the display.

C++
evoid lcd_flush_display( lv_display_t *disp, const lv_area_t *area, uint8_t * px_map) {
    size_t count = (area->x2-area->x1+1)*(area->y2-area->y1+1);
    for(int i = 0;i<count;++i) {
        uint16_t* p = &((uint16_t*)px_map)[i];
        *p = ((*p<<8)&0xFF00)|((*p>>8)&0xFF);
    }
    esp_lcd_panel_draw_bitmap(lcd_handle,area->x1,area->y1,area->x2+1,area->y2+1,px_map);
    LV_UNUSED(disp);
}


This is less efficient. It's also ugly. This is what's for dinner now in LVGL. This is "progress".

The worst part is I understand and even sort of agree with why they did it.

The issue is multiple displays, and the fact that some displays may not need the swap, perhaps because they're monochrome or something. Previously prior to 8 LVGL simply didn't support that scenario because the swap option was a #define (LVGL is C, not C++) and it applied to all displays as a consequence.

But to remove it entirely seems like it was a decision guided by expediency more than anything. It's unfortunate.

And all of it reminds me of why I hate the fact that humans couldn't universally agree on endian order.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix


modified 1-Jun-24 13:36pm.

GeneralRe: Blessed endian mismatches collide with progress Pin
Ron Anders1-Jun-24 8:26
Ron Anders1-Jun-24 8:26 
JokeRe: Blessed endian mismatches collide with progress Pin
PIEBALDconsult1-Jun-24 9:22
mvePIEBALDconsult1-Jun-24 9:22 
GeneralRe: Blessed endian mismatches collide with progress Pin
trønderen1-Jun-24 11:13
trønderen1-Jun-24 11:13 
GeneralRe: Blessed endian mismatches collide with progress Pin
honey the codewitch1-Jun-24 11:33
mvahoney the codewitch1-Jun-24 11:33 
GeneralRe: Blessed endian mismatches collide with progress Pin
trønderen1-Jun-24 12:39
trønderen1-Jun-24 12:39 
GeneralRe: Blessed endian mismatches collide with progress Pin
honey the codewitch1-Jun-24 12:47
mvahoney the codewitch1-Jun-24 12:47 
GeneralRe: Blessed endian mismatches collide with progress Pin
trønderen2-Jun-24 4:32
trønderen2-Jun-24 4:32 
GeneralRe: Blessed endian mismatches collide with progress Pin
honey the codewitch2-Jun-24 4:34
mvahoney the codewitch2-Jun-24 4:34 
GeneralRe: Blessed endian mismatches collide with progress Pin
11917640 Member 2-Jun-24 1:40
11917640 Member 2-Jun-24 1:40 
GeneralRe: Blessed endian mismatches collide with progress Pin
kalberts2-Jun-24 4:34
kalberts2-Jun-24 4:34 
GeneralRe: Blessed endian mismatches collide with progress Pin
11917640 Member 2-Jun-24 18:10
11917640 Member 2-Jun-24 18:10 
GeneralRe: Blessed endian mismatches collide with progress Pin
jochance6-Jun-24 6:33
jochance6-Jun-24 6:33 
Generalimplementing interface method, same signature, from two interfaces Pin
raddevus25-Apr-24 9:55
mvaraddevus25-Apr-24 9:55 
GeneralRe: implementing interface method, same signature, from two interfaces Pin
Jon McKee25-Apr-24 12:27
professionalJon McKee25-Apr-24 12:27 
GeneralRe: implementing interface method, same signature, from two interfaces Pin
Richard Deeming30-Apr-24 0:30
mveRichard Deeming30-Apr-24 0:30 
GeneralRe: implementing interface method, same signature, from two interfaces Pin
honey the codewitch2-May-24 13:49
mvahoney the codewitch2-May-24 13:49 
RantGiven enough eyeballs - a Sunday rant... Pin
Mircea Neacsu21-Apr-24 7:32
Mircea Neacsu21-Apr-24 7:32 
GeneralRe: Given enough eyeballs - a Sunday rant... Pin
Greg Utas21-Apr-24 8:10
professionalGreg Utas21-Apr-24 8:10 
GeneralRe: Given enough eyeballs - a Sunday rant... Pin
Mircea Neacsu21-Apr-24 8:18
Mircea Neacsu21-Apr-24 8:18 
GeneralRe: Given enough eyeballs - a Sunday rant... Pin
Greg Utas21-Apr-24 10:11
professionalGreg Utas21-Apr-24 10:11 
GeneralRe: Given enough eyeballs - a Sunday rant... Pin
charlieg21-May-24 23:52
charlieg21-May-24 23:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.