Click here to Skip to main content
15,887,596 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
AnswerRe: So the Dell firmware "flash" update / Windows update bricked my laptop Pin
0x01AA23-Sep-23 12:52
mve0x01AA23-Sep-23 12:52 
GeneralRe: So the Dell firmware "flash" update / Windows update bricked my laptop Pin
Nelek24-Sep-23 3:43
protectorNelek24-Sep-23 3:43 
AnswerRe: So the Dell firmware "flash" update / Windows update bricked my laptop Pin
Nelek24-Sep-23 3:45
protectorNelek24-Sep-23 3:45 
AnswerRe: So the Dell firmware "flash" update / Windows update bricked my laptop Pin
charlieg24-Sep-23 6:04
charlieg24-Sep-23 6:04 
GeneralRe: So the Dell firmware "flash" update / Windows update bricked my laptop Pin
Marc Clifton25-Sep-23 13:38
mvaMarc Clifton25-Sep-23 13:38 
AnswerRe: So the Dell firmware "flash" update / Windows update bricked my laptop Pin
Jeremy Falcon25-Sep-23 6:20
professionalJeremy Falcon25-Sep-23 6:20 
GeneralGet Carter 2000 Musical excerpt very catchy Pin
jmaida22-Sep-23 16:18
jmaida22-Sep-23 16:18 
GeneralFrom code shim to emulator Pin
honey the codewitch22-Sep-23 15:09
mvahoney the codewitch22-Sep-23 15:09 
I started creating a way to connect devices to Winduino. You literally load up the hardware, which is a dll, and then you can set some arbitrary configuration properties if necessary, then you can connect the wires together - literally pin to pin connections from your virtual Arduino board to your virtual sensor, display, or other module.

Implementing an SPI slave and master setup by virtually bit-banging (both master/host and slave/device) at both ends is weird, fun, and challenging. It's basically emulating the hardware enough that you can then build the HAL code on top of that.

Here's code in the slave for processing incoming data as the SPI CLK line changes, looking for particular commands in the stream, and updating the framebuffer as SPI data comes in, much like the actual hardware would do. It's neat.

C++
static void process_byte(uint8_t val) {
    if (can_configure) return;
    if (dc.value()) {
        switch (st) {
            case STATE_WRITE:
                switch (offset) {
                    case 0:
                        write_col = val << 8;
                        ++offset;
                        ++bytes_written;
                        break;
                    case 1:
                        write_col |= val;
                        uint8_t r = ((float)((write_col >> 11) & 31) / 31.0f) * 255;
                        uint8_t g = ((float)((write_col >> 5) & 63) / 63.0f) * 255;
                        uint8_t b = ((float)((write_col >> 0) & 31) / 31.0f) * 255;
                        if (WAIT_OBJECT_0 == WaitForSingleObject(
                                                 render_mutex,  // handle to mutex
                                                 INFINITE)) {   // no time-out interval)
                            uint8_t* p = &frame_buffer[column + screen_size.width * row * 4];
                            *p++ = b;
                            *p++ = g;
                            *p++ = r;
                            *p = 0xFF;
                        }
                        ++column;
                        if (column > col_end) {
                            ++row;
                            if (row > row_end) {
                                st = STATE_IGNORING;
                                break;
                            }
                        }
                        ++bytes_written;
                        offset = 0;
                        break;
                }

                break;

            default:
                if (cmd_args_cap == 0) {
                    cmd_args_cap = 16;
                    cmd_args_size = 0;
                    cmd_args = (uint8_t*)malloc(cmd_args_cap);
                    if (cmd_args == nullptr) {
                        return;
                    }
                } else if (cmd_args == nullptr) {
                    return;
                }
                if (cmd_args_size >= cmd_args_cap) {
                    cmd_args_cap += (cmd_args_cap * .8);
                    cmd_args = (uint8_t*)realloc(cmd_args, cmd_args_cap);
                    if (cmd_args == nullptr) {
                        return;
                    }
                }
                cmd_args[cmd_args_size++] = val;
                switch (st) {
                    case STATE_COLSET:
                        if (cmd_args_size == 4) {
                            uint16_t r = cmd_args[0] << 8;
                            r |= cmd_args[1];
                            col_start = r;
                            r = cmd_args[2] << 8;
                            r |= cmd_args[3];
                            col_end = r;
                            cmd_args_size = 0;
                            column = col_start;
                            st = STATE_IGNORING;
                        }
                        break;
                    case STATE_ROWSET:
                        if (cmd_args_size == 4) {
                            uint16_t r = cmd_args[0] << 8;
                            r |= cmd_args[1];
                            row_start = r;
                            row = row_start;
                            r = cmd_args[2] << 8;
                            r |= cmd_args[3];
                            row_end = r;
                            cmd_args_size = 0;
                            st = STATE_IGNORING;
                        }
                    case STATE_WRITE:
                        if (bytes_written == sizeof(uint16_t) * (row_end - row_start + 1) * (col_start - col_end + 1)) {
                            st = STATE_IGNORING;
                        }
                        break;
                }
                break;
        }
    } else {
        bytes_written = 0;
        bytes_read = 0;
        cmd = val;
        if (cmd == colset) {
            st = STATE_COLSET;
        } else if (cmd == rowset) {
            st = STATE_ROWSET;
        } else if (cmd == write) {
            st = STATE_WRITE;
        } else if (cmd == read) {
            st = STATE_READ;
        } else {
            st = STATE_IGNORING;
            cmd_args_size = 0;
        }
    }
}
static void on_clk_changed(void* state) {
    if (cs.value()) return;
    if (clk.value()) {
        if (bit_count == 8) {
            process_byte(in_byte);
            bit_count = 0;
            in_byte = 0;
        }
        in_byte |= mosi.value();
        ++bit_count;
    } else {
        in_byte << 1;
    }
}

Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Generalworldle 609 3/6 Pin
jmaida22-Sep-23 15:01
jmaida22-Sep-23 15:01 
GeneralWordle 826 Pin
StarNamer@work22-Sep-23 13:50
professionalStarNamer@work22-Sep-23 13:50 
GeneralRe: Wordle 826 Pin
GKP199222-Sep-23 19:28
professionalGKP199222-Sep-23 19:28 
GeneralRe: Wordle 826 - 4 4 me Pin
pkfox22-Sep-23 20:51
professionalpkfox22-Sep-23 20:51 
GeneralRe: Wordle 826 Pin
OriginalGriff22-Sep-23 19:43
mveOriginalGriff22-Sep-23 19:43 
GeneralRe: Wordle 826 Pin
Sandeep Mewara22-Sep-23 21:43
mveSandeep Mewara22-Sep-23 21:43 
GeneralRe: Wordle 826 Pin
Cp-Coder22-Sep-23 23:09
Cp-Coder22-Sep-23 23:09 
GeneralRe: Wordle 826 Pin
Sander Rossel23-Sep-23 0:08
professionalSander Rossel23-Sep-23 0:08 
GeneralRe: Wordle 826 Pin
Amarnath S23-Sep-23 4:58
professionalAmarnath S23-Sep-23 4:58 
GeneralRe: Wordle 826 5/6 Pin
jmaida23-Sep-23 15:31
jmaida23-Sep-23 15:31 
GeneralRe: Wordle 826 (4/6) Pin
Jeremy Falcon23-Sep-23 16:37
professionalJeremy Falcon23-Sep-23 16:37 
GeneralI Broke It! Pin
Roger Wright22-Sep-23 11:56
professionalRoger Wright22-Sep-23 11:56 
JokeRe: I Broke It! Pin
Peter_in_278022-Sep-23 12:45
professionalPeter_in_278022-Sep-23 12:45 
GeneralRe: I Broke It! Pin
charlieg23-Sep-23 1:57
charlieg23-Sep-23 1:57 
GeneralRe: I Broke It! Pin
Andreas Mertens23-Sep-23 4:43
professionalAndreas Mertens23-Sep-23 4:43 
GeneralRe: I Broke It! Pin
Richard Andrew x6423-Sep-23 8:21
professionalRichard Andrew x6423-Sep-23 8:21 
GeneralRe: I Broke It! Pin
englebart24-Sep-23 13:15
professionalenglebart24-Sep-23 13:15 

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.