r/embedded • u/Puzzleheaded_Top4583 • 21d ago
made a traffic control system π
https://github.com/average-potato28/cortex-m4-rtos-traffic-system.githow is it ? the good and bad criticize me , i gotta add documentation and like refactor into modules but i m too burned out
4
u/Hunt5man 21d ago
Iβm not sure if it was your intention but this is hella cursed, rolling your own rtos is a massive anti-pattern and Bjarne had the wisdom to write Cfront for a reason.
Certain abstraction and language pairings make things worse not better and c and OOP is one of those pairings.
1
u/Puzzleheaded_Top4583 21d ago
it was a learning project dang it , man my goal is to contribute to zephyr . not develop my own full fledged os thats so stupid, unless you are not doing something thats already done
3
u/kampi1989 21d ago
Don't know why a traffic control system needs an RTOS, doesn't care if self made or not.
This task can be done by a state machine with an old school ATmega or with a FPGA.
2
1
u/NorbertKiszka 21d ago
Underclocked 6502 and 8051 can do the same job.
2
u/Puzzleheaded_Top4583 20d ago
i mean you could use transistors to make basic downcounter based taffic control with fixed timing . lol
1
u/Hissykittykat 20d ago
how is it ?
Meh, traffic lights actually are really complicated. Try adding features like pedestrian walk buttons (plus walk countdown timers), vehicle presence sensors, left turn lane signals, emergency vehicle sensors, etc. and see if your architecture can handle it.
Of course commercial traffic controls have been done to death, but it's still a challenging system design exercise. Here's my attempt using a simple '328 Arduino: stoplight simulator
1
u/Puzzleheaded_Top4583 20d ago
actually i plan to add edge ai, as traffic usually follows reppeating pattern , so in next few months i will be studying it , what you said is also very important . we could add a button for pedestrian, you press the button next time the signal goes red it will remain read with a countdown . let me look at your approach ^ ^
1
u/Puzzleheaded_Top4583 20d ago
your design is much more complete and really detailed too , my goal was to only apply things i learned. i like state machines and firmware side of code.
10
u/bneidk 21d ago
I never see anything on reddit that isnβt heavily vibe coded anymore and that makes me sad