|
why does gong mean medal - Google Search[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I looked over a jillion meanings of gong but found no connection to Medal. However, I did find that a lion gong is also known as a wind going or a feng. You don't even want to know how far down that rabbit hole I went!
|
|
|
|
|
I'm headdesking this code I'm trying to port. It's just a godawful mess. I'm barely treading water, even as I understand about 70% of it more or less, it's really difficult to modify.
https://github.com/KurtE/ILI9341_t3n
specifically:
https://github.com/KurtE/ILI9341_t3n/blob/master/src/ILI9341_t3n.cpp
Kurt's a nice guy. I've corresponded with him, not about this code directly, but about my attempt at making similar code that works with htcw_gfx, my graphics library for IoT devices.
That said, I hate the way he coded this. I feel like design was either an afterthought, or he just added to it over and over without ever bothering to step back and refactor. I've done that too, so it's not really a judgment of his coding in general, but it *is* difficult to deal with in this case.
Now I need to though, because for starters his device reads are not const (if you know C++ then you should understand the ramifications of that) and they aren't easily made const because of the way it's implemented, so if I want to read pixels off the display device I can't do that, because htcw_gfx expects readable things to be able to const.
I can fix that by moving all the driver communication code to a static template class whose arguments include the DC and CS pins, so I have statics per SPI device, but it means open heart surgery on Kurt's code, and I'm kind of overwhelmed trying to piece this all together. This is already my second attempt.
I love building things, but sometimes the act itself stifles the creative part. Like, the inspiration for the creation vs the act of creation itself - sometimes they are at odds. Hebrew has words for each part of that creative process. I wish English did.
To err is human. Fortune favors the monsters.
modified 31-Aug-22 2:08am.
|
|
|
|
|
From a very quick scan the things that concern me with that code aren't whether reads are const or not. The number of "TODO", "BUG" and commented out lines imply that it hasn't been finished.
May be suitable for what you need but having a clean codebase you can trust is far more important than whether it is fully optimised for language semantics.
|
|
|
|
|
There's a bunch of that too.
I'd love a clean codebase, but this code does black magic with the ARM Cortex M7 SPI registers, and I don't know enough about it to write it from scratch.
To err is human. Fortune favors the monsters.
|
|
|
|
|
You could take the time to reverse engineer it. Then again, I remember a comment in somewhat similar code at a previous job: "Abandon hope, all ye who look at this code. Not even its author understands how it works, or why."
|
|
|
|
|
https://www.pjrc.com/teensy/K20P64M72SF1RM.pdf
Starting at page 913 or so.
Reading this nonsense is like reading sheet music to me - I can get it, if I squint, and I pray.
This is what I'd be reverse engineering to get at.
This is some of the code. It's all like this:
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
#define TCR_MASK \
(LPSPI_TCR_PCS(3) | LPSPI_TCR_FRAMESZ(31) | LPSPI_TCR_CONT | LPSPI_TCR_RXMSK)
void maybeUpdateTCR(
uint32_t requested_tcr_state) {
if ((_spi_tcr_current & TCR_MASK) != requested_tcr_state) {
bool dc_state_change = (_spi_tcr_current & LPSPI_TCR_PCS(3)) !=
(requested_tcr_state & LPSPI_TCR_PCS(3));
_spi_tcr_current = (_spi_tcr_current & ~TCR_MASK) | requested_tcr_state;
if (!dc_state_change || !_dcpinmask) {
while ((_pimxrt_spi->FSR & 0x1f))
;
_pimxrt_spi->TCR = _spi_tcr_current;
} else {
waitTransmitComplete();
if (requested_tcr_state & LPSPI_TCR_PCS(3))
DIRECT_WRITE_HIGH(_dcport, _dcpinmask);
else
DIRECT_WRITE_LOW(_dcport, _dcpinmask);
_pimxrt_spi->TCR = _spi_tcr_current &
~(LPSPI_TCR_PCS(3) |
LPSPI_TCR_CONT); }
}
}
void writecommand_cont(uint8_t c) __attribute__((always_inline)) {
maybeUpdateTCR(_tcr_dc_assert | LPSPI_TCR_FRAMESZ(7) );
_pimxrt_spi->TDR = c;
pending_rx_count++; waitFifoNotFull();
}
void writedata8_cont(uint8_t c) __attribute__((always_inline)) {
maybeUpdateTCR(_tcr_dc_not_assert | LPSPI_TCR_FRAMESZ(7) | LPSPI_TCR_CONT);
_pimxrt_spi->TDR = c;
pending_rx_count++; waitFifoNotFull();
}
void writedata16_cont(uint16_t d) __attribute__((always_inline)) {
maybeUpdateTCR(_tcr_dc_not_assert | LPSPI_TCR_FRAMESZ(15) | LPSPI_TCR_CONT);
_pimxrt_spi->TDR = d;
pending_rx_count++; waitFifoNotFull();
}
To err is human. Fortune favors the monsters.
|
|
|
|
|
I think of someone else's code as clay; to be reworked if necessary; incrementally. Reworking code also helps me understand it better; even if it's just changing local variable names. But just staring at it ... not so much. Be one with the code.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
All I can say is you have not seen this code.
To err is human. Fortune favors the monsters.
|
|
|
|
|
Reformat file to tab/space/bracket system that your mind comprehends best.
Start with one variable. Figure out what it does. Universally rename it so you can understand it and not think about it again.
Repeat x 1 billion or so.
Continually perform incantations to the appropriate gods, including all the curse words you know, and make up some for good measure.
Swear some more.
Before you know it, success!!!
|
|
|
|
|
I can't rename the processor's SPI register constants.
Let me show you what I'm working with.
Frankly the variable names don't bother me. There aren't many variables, and I understand most of the class members like _csport and _dcport at this point. My main issue is the behavior of the registers. I have the manual but it reads like bad stereo instructions
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
#define TCR_MASK \
(LPSPI_TCR_PCS(3) | LPSPI_TCR_FRAMESZ(31) | LPSPI_TCR_CONT | LPSPI_TCR_RXMSK)
void maybeUpdateTCR(
uint32_t requested_tcr_state) {
if ((_spi_tcr_current & TCR_MASK) != requested_tcr_state) {
bool dc_state_change = (_spi_tcr_current & LPSPI_TCR_PCS(3)) !=
(requested_tcr_state & LPSPI_TCR_PCS(3));
_spi_tcr_current = (_spi_tcr_current & ~TCR_MASK) | requested_tcr_state;
if (!dc_state_change || !_dcpinmask) {
while ((_pimxrt_spi->FSR & 0x1f))
;
_pimxrt_spi->TCR = _spi_tcr_current;
} else {
waitTransmitComplete();
if (requested_tcr_state & LPSPI_TCR_PCS(3))
DIRECT_WRITE_HIGH(_dcport, _dcpinmask);
else
DIRECT_WRITE_LOW(_dcport, _dcpinmask);
_pimxrt_spi->TCR = _spi_tcr_current &
~(LPSPI_TCR_PCS(3) |
LPSPI_TCR_CONT); }
}
}
void writecommand_cont(uint8_t c) __attribute__((always_inline)) {
maybeUpdateTCR(_tcr_dc_assert | LPSPI_TCR_FRAMESZ(7) );
_pimxrt_spi->TDR = c;
pending_rx_count++; waitFifoNotFull();
}
void writedata8_cont(uint8_t c) __attribute__((always_inline)) {
maybeUpdateTCR(_tcr_dc_not_assert | LPSPI_TCR_FRAMESZ(7) | LPSPI_TCR_CONT);
_pimxrt_spi->TDR = c;
pending_rx_count++; waitFifoNotFull();
}
void writedata16_cont(uint16_t d) __attribute__((always_inline)) {
maybeUpdateTCR(_tcr_dc_not_assert | LPSPI_TCR_FRAMESZ(15) | LPSPI_TCR_CONT);
_pimxrt_spi->TDR = d;
pending_rx_count++; waitFifoNotFull();
}
To err is human. Fortune favors the monsters.
|
|
|
|
|
honey the codewitch wrote: I can't rename the processor's SPI register constants. The magic of C++ macros allows any possibility! Have fun swearing!
|
|
|
|
|
Anarchy,
Open source is wierd. I took a look at the link you posted. It's a fork of a library written by Paul Stoffregen[^] under the MIT license.
Looking at that guys code reveals that it's yet another fork of the Adafruit library[^] with the BSD license removed.
So it looks like:
- Kurt (MIT licensed fork of PaulStoffregen)
- PaulStoffregen (MIT licensed fork of Adafruit)
- Adafruit original code is BSD licenced.
It honestly feels like you'd need an army of lawyers to use alot of open source code. I've always avoided it.
|
|
|
|
|
I'm aware of where it came from, and I'm very familiar with the Adafruit rendition.
The thing about Paul and Kurt's implementations is they are both optimized for the teensy, with Kurt's essentially being mostly the same as Paul's except with DMA.
The teensy specific stuff is what I'm copying. I need nothing from Adafruit, so as far as I'm concerned what I'm copying is MIT, as is what I wrote. If Adafruit wants to come at me, they can sure try. Otherwise, I feel like this is fair use.
Most of the IoT ecosystem is open source, so you either get used to it, or find another arena to develop in.
To err is human. Fortune favors the monsters.
|
|
|
|
|
#Worldle #222 2/6 (100%)
π©π©π©π¨β¬β¬
οΈ
π©π©π©π©π©π
https://worldle.teuteuf.fr
Todays Worldle will be dear to CP.
|
|
|
|
|
Quote: #Worldle #222 2/6 (100%)
π©π©π©π¨β¬β¬
οΈ
π©π©π©π©π©π
https://worldle.teuteuf.fr I'm just guessing we both went with the same first try!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
#Worldle #222 1/6 (100%)
π©π©π©π©π©π
https://worldle.teuteuf.fr
|
|
|
|
|
Too easy today
#Worldle #222 1/6 (100%)
π©π©π©π©π©π
https://worldle.teuteuf.fr
Happiness will never come to those who fail to appreciate what they already have. -Anon
|
|
|
|
|
I dont get all the 1/6! not a natural starter for me...
Wordle 438 6/6
β¬π©β¬π¨β¬
β¬β¬β¬β¬π©
π©π©π©β¬π©
π©π©π©β¬π©
π©π©π©β¬π©
π©π©π©π©π©
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
I consider CP to be sort of family - kudos or a's to Chris - he's Canadian, he'll get it.
I want all of you to look around or think of your loved ones - kids, wife, husband, etc and appreciate them. You do not know how long you will have them.
I buried my Mom in June. This morning, my younger sister passed. I have 3 sons in the USARMY - all tip of the spear stuff. I never saw this with my sister.
Yeah, it hurts like hell. Take a moment to count your blessings and hug loved ones.
elephant
Charlie Gilley
βThey who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.β BF, 1759
Has never been more appropriate.
|
|
|
|
|
Amen! And I'd include friends in that list as well. I lost one of my best friends 2 days ago...known him for many, many years, just like a brother to me. All we are promised is today, so use it well!
|
|
|
|
|
My close friend's younger brother, aged 53, passed away suddenly of heart attack. Nothing can be expected in this world.
|
|
|
|
|
Condolences
|
|
|
|
|
My condolences.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
A difficult part of life, my condolences.
Some time back, a good friend sent me this:
A Keeper
Their marriage was good, their dreams focused.
Their best friends lived barely a wave away.
I can see them now,
Dad in trousers, tee shirt and a hat and Mom in a house dress,
lawn mower in one hand, and dish-towel in the other.
It was the time for fixing things.
A curtain rod, the kitchen radio, screen door, the oven door, the hem in a dress.
Things we keep.
It was a way of life, and sometimes it made me crazy.
All that re-fixing, eating, renewing,
I wanted just once to be wasteful.
Waste meant affluence.
Throwing things away meant you knew there would always be more.
But then my mother died, and on that clear summer's night,
in the warmth of the hospital room,
I was struck with the pain of learning that sometimes there isn't any more.
Sometimes, what we care about most gets all used up and goes away...
never to return.
So... While we have it... it's best we love it...
And care for it.... And fix it when it's broken.....
And heal it when it's sick.
This is true...
For marriage....
And old cars....
And children with bad report cards.....
Dogs and cats with bad hips....
And aging parents....
And grandparents.
We keep them because they are worth it, because we are worth it.
Some things we keep.
Like a best friend that moved away or a classmate we grew up with.
There are just some things that make life important, like people we know who are special....
And so, we keep them close!
I received this from someone who thinks I am a 'keeper',
so I've sent it to the people I think of in the same way...
Good friends are like stars....
You don't always see them, but you know they are always there
People are made to be Loved and Things are made to be Used
There is so much confusion in this World because
People are being Used
and
Things are being Loved.
Be kind... everyone you meet is fighting a terrible battle.
Thanks for being part of MY life!
>64
Some days the dragon wins. Suck it up.
|
|
|
|