#avr Logs

Dec 23 2017

#avr Calendar

05:44 AM Emil: nuxil: the cast is done first
05:47 AM Emil: nuxil: (uint8_t)(SG.acc>>16); would be the correct one
08:26 AM nuxil: Emil, alright. any ideas to why the usage of uint32 in that line besides confusing people ?
08:33 AM nuxil: jup your right Emil, (uint8_t)abc>>8, `abc` converted to uint8_t shifted right by 8. while (uint8_t)(abc>>8) , `abc` shifted right by 8 converted to uint8_t
08:34 AM nuxil: kind of usefull this bot in ##C :p
08:35 AM nuxil: nuxil> ,english (uint8_t)abc>>8
08:35 AM nuxil: and it replys: nuxil: `abc` converted to uint8_t shifted right by 8.
08:45 AM antto: geordi is more useful ;P~
08:45 AM nuxil: who/what is that ?
08:46 AM antto: the bot in #c++
08:46 AM nuxil: meh.. c++
08:47 AM nuxil: i dont like c++.
08:47 AM antto: why?
08:48 AM nuxil: because its to big and complex for my tiny brain.
08:48 AM antto: so is the universe, but you live in it
08:49 AM nuxil: hehe
09:25 AM nuxil: antto, besides. im not that much into programming. i do not develop big apps used on desktop or in other systems, and the stuff do with the mcu's C is more than enough for me. and if i need something quickly dont in short time that doesnt require high performance i use python. for py gui apps i usaly go with wxwidgets bindings.
09:27 AM antto: so, you said why you like this and that, but didn't say why you don't like c++
09:27 AM antto: ;P~
09:27 AM nuxil: i said it. i find it to complex to use/learn
09:28 AM antto: so then, if i learn C++ more than now, i would find it complex
09:30 AM nuxil: antto, aslo. i have no reason to learn c++ when im not gonna code in it. i can read some basic c++ sure. but why should i start learning someting that i will not really use?
10:07 AM dev1990: nuxil: some of modern C++ are really handy and make life easier and efficient, I think C should adopt some C++ feature like constexpr functions, raii (for memory managment), static_asserts without all OOP stuff
10:09 AM nuxil: C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow away your whole leg! — Bjarne Stroustrup
10:10 AM nuxil: :)
10:10 AM antto: is there anything stopping you from using just the X% of C++ which you find useful?
10:10 AM nuxil: read this old article instead.
10:10 AM nuxil: https://simpleprogrammer.com/2012/12/01/why-c-is-not-back/
10:12 AM dev1990: nuxil: I like that quote, but this OOP is about shooting at legs if is not designed well
10:13 AM dev1990: let's talk about C with some features that C++ introduce (think about them like, some by mistake add somethink helpful in C++)
10:13 AM nuxil: There was am in idea back in the 90's about splitting up C++ into two parts. C++ Top and C++ Bottom. but i cant find that article again. it was a nice idea.
10:16 AM dev1990: this is old article and probably they don't know about common stuff that was introduced while ago
10:18 AM nuxil: can you give 3 good reasons to learn C++?
10:19 AM dev1990: nuxil: do you want to improve your C ?
10:19 AM nuxil: well. im not that good at C so yes.
10:21 AM dev1990: I think learning something else will improve your C and C++ is special becouse there much in common and you can create a list like C++ features that are useless to you and list features that you find not useless
10:21 AM nuxil: but i mean. i dont see myself having the need to know template metaprogramming, mpi. and to build complicated apps that need classes, constructors, deconstructors so on. so much stuff in C++ i will not need.
10:23 AM nuxil: i mostly do scripting in python. and the C im learning is just so i can contoll the pins on my mcu :p i had no other reason to learn C
10:23 AM nuxil: so why go C++ when the few lines of code i need in C will do the job i need to be done
10:25 AM dev1990: nuxil: is it always that way ? like three lines and you are done ?
10:25 AM nuxil: its like you need a micro plane to get to A to B.. why get a license for a fully commercial plane :p
10:26 AM nuxil: heh a bit more than 3 lines
10:26 AM dev1990: how many ?
10:27 AM nuxil: what ?
10:28 AM nuxil: for my current project ? hmm i use old libs that i cleaned up and modified using Jartza's macros. then i got my own display code im working on. but cant test it jet. it all in all at around 900 lines now.
10:31 AM nuxil: *jet ->yet.idk what i always type yet as jet :p
10:32 AM dev1990: 1. "old libs that i cleaned up" - you're improving stuff that's feel good in every language even in C++
10:33 AM dev1990: 2. "modified using Jartza's macros" - you're using some ideas that make your C more robust and efficient
10:33 AM nuxil: i like his macros
10:33 AM nuxil: :)
10:35 AM dev1990: I like C++ standard templates for example (for std::array, std::vector) :) found them really helpfull and whole community supports them, from my side little
10:35 AM nuxil: i have mostly written up the ic2 code for the display. but i dont have a ic2 device i can test it with.
10:35 AM dev1990: you like that feel when some of your C functions can be shorter ?
10:36 AM dev1990: like clever idea, macro, etc
10:36 AM nuxil: but i got a nucleo the other day and was thinking about setting it up as a i2c slave and simulate the display im awaiting. got all info needed on them tho.
10:36 AM nuxil: but meh im thinking, by the time im done with that. they have arrived in the mail :p
10:38 AM nuxil: yes. shorter more readeble functions is good.
10:40 AM nuxil: and names on marcos a normal person understand :p
10:42 AM dev1990: I think you're wrong on that, because knowlage is needed and it's not trivial, many C++ programers don't know what to do with those macros
10:45 AM nuxil: really ? i mean. take Jartza's macros as a example "avr_common_macros" even i can understand whats going on there :p surly a c++ programmer would understand them aswell if he looked at the definition
10:47 AM nuxil: and isnt the macros & the preprosessor a thingy for C++ aswell? so its something you should know about anyway?
10:49 AM dev1990: if you want to program pure C++ they are against macros, C++ introduce harded to understand "macros" - templates that compiler understand (but many of C++ programers don't like to write templates, and this is also kind of magic for them)
10:51 AM dev1990: and I know what you're thinking right now
10:51 AM dev1990: fuu them :)
10:51 AM nuxil: lol
10:51 AM dev1990: but I know concept about macros and templates and goal is same
10:53 AM Jartza: evening
10:53 AM nuxil: hi
10:53 AM dev1990: well am I wrong ?
10:53 AM Jartza: hi
10:53 AM dev1990: hi
10:54 AM Jartza: what's up?
10:54 AM nuxil: drinking coffee and discussing c/c++ :p
10:54 AM Jartza: :)
10:55 AM Jartza: I also got my panamian coffee order
10:56 AM Jartza: https://drive.google.com/file/d/1DSsf7sbpmkJxAIWCrV3EHkVDKBKYtJLD/view?usp=sharing
10:56 AM Jartza: I hope that will last for a while :)
10:56 AM nuxil: sounds exsotic. i just drink kadde
10:56 AM nuxil: *kaffe
10:56 AM dev1990: ok so coffe stuff is there
10:56 AM dev1990: we can continue this C++ my ass conversation :)
10:57 AM nuxil: friele kaffe
10:57 AM nuxil: dev1990, yea isnt their end goal the same.? macros and templates.? i guess templates are a bit more powerfull tho
10:58 AM dev1990: did you know that in C++17 is possible to write C compiler that compile C on compile time of C++ program ?
10:58 AM Jartza: I submitted this PR yesterday and now I'm on holiday until 4th of January https://i.imgur.com/rlZrQAe.png?1
10:59 AM dev1990: even in C++14
10:59 AM dev1990: yeah goals are same but some of c++ designs are more powerfull, and some of those features are somethink that C can benefit on
11:00 AM nuxil: Jartza, ? whats that youre working on?
11:00 AM Jartza: customer projects, as always
11:00 AM Jartza: current customer is Suunto
11:01 AM Jartza: working on products that will be on shops next year
11:01 AM nuxil: :)
11:02 AM Jartza: and I've worked with Spartan -watches for some time now
11:04 AM Jartza: jumped into Telia-project for 6 months and then back to Suunto
11:04 AM nuxil: dev1990, try and convince some of the members in the C standards committee :p
11:06 AM dev1990: probably I'm to stupid to talk with those guys
11:06 AM Jartza: why so?
11:06 AM Jartza: there was one guy from C++ commitee working with me in the suunto project :)
11:07 AM dev1990: that's nice, who is it ?
11:07 AM Jartza: can't really tell names :P
11:07 AM dev1990: let me help
11:07 AM Jartza: and in the end he wasn't too good coder IMO D
11:07 AM Jartza: D
11:07 AM Jartza: shit
11:07 AM Jartza: :D
11:07 AM nuxil: haha
11:08 AM Jartza: he was more interested in strange features of C++ compiler, than code quality and readability
11:08 AM dev1990: https://isocpp.org/wiki/faq/wg21
11:08 AM Jartza: but when there was a new feature in compiler, he was on a verge of an orgasm
11:08 AM nuxil: lol :p
11:09 AM nuxil: these suunto looks big
11:10 AM dev1990: it's ok if you don't know now, but maybe is worth to know guys name
11:10 AM dev1990: and read some stuff that he is working on
11:12 AM Jartza: dev1990: my NDA prevents me from telling, but nobody prevents telling I'm from Finland and Suunto is is Finland :D
11:12 AM Jartza: so you just have to guess, haha
11:13 AM Jartza: I can tell he's not Bjarne Stirsoup, or however that's spelled
11:13 AM nuxil: well hes dead isnt he :p
11:13 AM dev1990: successor of Bjarne then
11:14 AM Jartza: nuxil: no he's not :)
11:15 AM nuxil: i though i saw it in the newspaper some time ago :p fake news as usual :p
11:16 AM Jartza: maybe he just smells so funny people thought he's dead
11:17 AM nuxil: btw. i was thinking about Dennis MacAlistair Ritchie
11:17 AM Jartza: ahh yea
11:18 AM Jartza: creator of C
11:18 AM nuxil: jup
11:24 AM Jartza: maybe now on christmas vacation I have time to create the new tagsu pcb
11:24 AM nuxil: what updates are you doing on it ?
11:25 AM dev1990: can we talk about this C source file (https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/drivers/tty/amiserial.c?h=v4.14.8) about short break ? from semantic aspect rather than implementation
11:26 AM nuxil: amiga :D
11:26 AM dev1990: this is random pick, but I want to pinpoint some of features that c++ can lend C and make C better
11:27 AM Jartza: new power booster and moving to kicad
11:27 AM dev1990: can be lend to C *
11:28 AM dev1990: or mayby why use c++ to get only fraction of features and do not blown legs
11:36 AM nuxil: fuatures like ?
11:45 AM Emil: nuxil: castinhg is anyways useless with unsigned values
11:47 AM nuxil: Emil, not true :p let say you want last byte in a 32bit uint. then doing (uint8_t)var it less typing then doing the bitshifting :p
11:48 AM Emil: nuxil: wat
11:48 AM Emil: mate
11:48 AM Emil: wat
11:49 AM nuxil: yea. casting make it keep the last byte
11:49 AM Emil: ...
11:49 AM Emil: you do realise
11:50 AM Emil: that that is the defauöt
11:50 AM Emil: if you have a 32 bit variable that you assign to a 8 bit variaböe
11:50 AM Emil: you get the lowest byte
11:51 AM Emil: uint8_t v=some_32_bit_var; is equivalent to uint8_t v=(uint8_t)some_32_bit_var
11:52 AM nuxil: yes. but my question remains unanswered. why does he do (uint_8)((uint32_t)var>>n) when var is already 32bit,
11:52 AM Emil: because shit code
11:52 AM nuxil: lolz
11:52 AM Emil: because he's shit
11:52 AM Emil: because he autogenerated code
11:52 AM Emil: dunno
11:53 AM nuxil: its just confusing as f.
11:54 AM Emil: then remoce t
11:54 AM Emil: it's unnecessary
11:54 AM nuxil: yea done that.
11:54 AM Emil: p
11:55 AM Emil: so
11:55 AM Emil: do you still say I'm wrong?
11:56 AM nuxil: yes i get what you mean.
12:01 PM nuxil: but sometimes you want to cast. lets say you dont want to assign new variables in your code. but want to feed a H Byte and L Byte part of a var to a func that takes two or more 8 uint as argument.
12:08 PM Jartza: there's no need for cast even then
12:08 PM nuxil: surer?
12:08 PM Jartza: let's say you have like uint16_t foo = 12345;
12:08 PM Jartza: and function that takes uint8_t x, uint8_t y
12:09 PM Jartza: just call function(foo >> 8, foo & 0xff)
12:09 PM nuxil: will the compiler would complain if i did that
12:09 PM nuxil: *would it not
12:09 PM rue_bed: I wonder if gcc would optimize that properlyt
12:10 PM Jartza: that I'm not sure
12:10 PM rue_bed: isn't there a highbyte() lowbyte() macro
12:10 PM rue_bed: used to be used in setting baud divisors and stuff
12:10 PM Jartza: dunno
12:10 PM rue_bed: might be from my PIC days...
12:11 PM Jartza: anyways (uint8_t)((uint32_t)var>>n) sounds stupid still :)
12:11 PM nuxil: yea.
12:15 PM Jartza: nuxil: and no, at least avr-gcc doesn't warn about that
12:16 PM nuxil: what im woundering. if you do. uint16_t v = 12345. then >> 8. will it be seens as a 16bit int with value 48?
12:17 PM nuxil: when you pass it to as a argument like in your example
12:18 PM Jartza: does it matter because it gets converted to 8bit anyway :)
12:19 PM nuxil: true. and if avr-gcc dosent warn or error it should work fine.
12:19 PM Jartza: the variable v is still 16bit, but what gets delivered as function argument is 8bit copy
12:20 PM Jartza: https://paste.ee/p/JZkEY
12:20 PM Jartza: avr-gcc -Wall -Wextra -pedantic -Os -std=c99 -DF_CPU=8000000 -mmcu=attiny85 main.c -o main.elf
12:21 PM Jartza: gives no warnings
12:21 PM dev1990: you can use https://godbolt.org/ to test if gcc produce efficient code
12:21 PM dev1990: rue_bed: ^^
12:22 PM dev1990: e
12:23 PM Jartza: nope
12:23 PM rue_bed: for avr?
12:24 PM Jartza: avr-objdump -d main.elf
12:24 PM dev1990: u can choose from list GCC for avr
12:24 PM Jartza: there's very old avr-gcc
12:24 PM dev1990: or setup compiler explorer on your host
12:25 PM Jartza: haha
12:25 PM Jartza: well the example above I gave compiles to 2 instructions :D
12:25 PM Jartza: essentially
12:25 PM Jartza: 30: 89 e6 ldi r24, 0x69 ; 105
12:25 PM Jartza: 32: 87 bb out 0x17, r24 ; 23
12:26 PM Jartza: of course there's vectors + ctors and the never-ending loop
12:28 PM Jartza: too simple example, I guess
12:30 PM dev1990: in this example everything is local, so it is very easy to optimize callside and etc
12:30 PM Jartza: yeah
12:31 PM dev1990: any way I prepare my version ;p in c++
12:32 PM Jartza: I write a lot of C++ too, but nothing fancy
12:32 PM dev1990: DDRB is register ?
12:32 PM Jartza: yes
12:35 PM dev1990: Jartza: what's your local gcc version ?
12:37 PM dev1990: http://wklej.org/hash/1542f7a91ce/ this should be compatible with c++11
12:38 PM dev1990: value is calculated at compile time with guarantee
12:39 PM dev1990: bar and ret don't have even address in memory
12:39 PM dev1990: should stay that way even with optimalization turn out
12:40 PM dev1990: turn off*
12:41 PM dev1990: nuxil: one of features that C should have
12:44 PM nuxil: whats going on there ? i get more instructions with same test
12:44 PM nuxil: eor r1, r1
12:44 PM nuxil: out 0x3f, r1
12:44 PM nuxil: ldi r28, 0x5F
12:44 PM nuxil: ldi r29, 0x02
12:44 PM nuxil: out 0x3e, r29
12:44 PM nuxil: out 0x3d, r28
12:45 PM Jartza: dev1990: 7.2.0
12:45 PM nuxil: o.O im soooo outdated
12:45 PM nuxil: lol.
12:45 PM nuxil: mine is 4.8.1
12:46 PM Jartza: nuxil: well you're looking at "__ctors_end"
12:46 PM nuxil: yes
12:46 PM Jartza: the code that initializes stack and stuff
12:46 PM Jartza: that's always there :)
12:46 PM Jartza: 00000030 <main>: 30: 89 e6 ldi r24, 0x69 ; 105 32: 87 bb out 0x17, r24 ; 23 34: ff cf rjmp .-2 ; 0x34 <main+0x4>
12:46 PM Jartza: whoa. nice looking paste. :P
12:47 PM Jartza: the main looks about like that
12:47 PM nuxil: exactly the same
12:47 PM Jartza: yeah, but pretty stupid example :P
12:48 PM dev1990: you mean my example ?
12:50 PM * dev1990 I'm confused
12:55 PM nuxil: hmm should the output be 9F ?
12:55 PM nuxil: *shoudnt
12:56 PM nuxil: "159"
12:57 PM Jartza: low byte 48, high 59 = 105 (0x6B)
01:00 PM nuxil: arg. ofc. had HEX in on my calulator and typed in 57+48 :p should have been in dec mode :p
01:00 PM Jartza: haha
01:01 PM dev1990: nuxil: hint, run python in cmd line mode
01:02 PM nuxil: no thanks. i hate coding directly in the interpreter.
01:03 PM nuxil: or you meant something else ?
01:03 PM dev1990: >>> 57+48
01:03 PM dev1990: 105
01:03 PM dev1990: >>> 0x57+0x48
01:03 PM dev1990: 159
01:03 PM dev1990: >>> hex(57+48)
01:03 PM dev1990: '0x69'
01:04 PM nuxil: i know
01:04 PM dev1990: it's pretty good calculator
01:04 PM dev1990: ;;p
01:23 PM kpo: C++ on micros FTW! well, You don't pay for stuff You won't use anyway
01:24 PM kpo: dev1990: i'm not python guy at all, but kudos for using its interpreter as calc, never thought of that before
01:35 PM dev1990: kpo: thanks ;p
01:38 PM dev1990: in C++20 we probably receive coroutines, this should be super helpful to write easy and efficient multitasking on avr and other platform
01:39 PM dev1990: https://en.wikipedia.org/wiki/Coroutine
01:39 PM rue_shop3: less that you should NEVER multitask on an 8 bit 16mips microcontroller
01:40 PM rue_shop3: or even a 20mips one
01:43 PM dev1990: rue_shop3: https://github.com/pietern/avr-tasks so is this completely useless?
01:44 PM rue_shop3: c++ on an avr is a bad idea
01:44 PM rue_shop3: and I know that all you are going to ask is WHY
01:44 PM rue_shop3: and I dont feel like explaining it
01:45 PM thardin: why would it?
01:45 PM rue_shop3: I have this preversion to use things efficiently, and nobody cares about that
01:45 PM thardin: you can still statically alloc everything
01:45 PM rue_shop3: which leads to things like 4Ghz processors used to flash an LED, using programming languages that take up gigs of memory to do it
01:46 PM rue_shop3: and people say "but it works"
01:46 PM thardin: and you'll still write asm for the critical parts
01:46 PM rue_shop3: sitting there pulling 300W to flash an led....
01:46 PM aczid: https://www.youtube.com/watch?v=zBkNBP00wJE
01:46 PM aczid: CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”
01:46 PM dev1990: aczid++
01:47 PM thardin: aczid: theres a decent compiler for 6502 now?
01:47 PM aczid: I have to say I prefer C over almost everything and have a hard time grasping most C++ concepts. but I try to keep an open mind and this talk was inspiring
01:47 PM thardin: cus cc65 is poop
01:47 PM rue_shop3: why NOT use minecraft logic as the core of your controller project, after all, you can get 4Ghz multi processors so cheap, and ram, whats a G of ram worth now, $10?
01:47 PM rue_shop3: why not use it?
01:47 PM aczid: I think this was gcc but could be completely wrong :)
01:48 PM dev1990: this was compiled from C++ to C then cc65 was used
01:48 PM thardin: that'd be neat
01:48 PM kpo: rue_shop3: of course it depends on scale and lifetime of product
01:48 PM thardin: dev1990: darn
01:48 PM kpo: for a huge run of short lifed products, sure go for plain C
01:48 PM dev1990: clang has backend that can generate C code from C++
01:48 PM aczid: ease of development goes a long way
01:49 PM kpo: but if you want to maintain a thing, go for c++
01:49 PM rue_shop3: I"m pretty sure there is a 6502 processor in minecraft
01:49 PM rue_shop3: pretty sure I saw static ram too
01:49 PM thardin: i'd use ada for micros if i knew it
01:49 PM aczid: I would dare say my C code is maintainable
01:49 PM rue_shop3: why not employ a whole datacenter to flash that led, I mean, if its out there use it right?
01:49 PM kpo: or if you are planning to create more lines of similar product, based on the same core system - using oop adding and reusing 'blocks' is easier than in c++
01:50 PM dev1990: rue_shop3: So you can compile C++17 magic to C then 6502 and run in minecraft :D
01:50 PM kpo: rue_shop3: you're talking shit with no arguments ;p
01:50 PM aczid: rue_shop3: there are reasonable compromises to be made
01:50 PM rue_shop3: no, I'm just saying that if you can max out a 4Ghz 8 core machine with 4G of ram to flash an led, why not?
01:51 PM rue_shop3: I mean, everything it so available
01:51 PM kpo: hurr durr, c++ is heavy, people are stupid, back in the day we used tiny computing power to land on moon
01:52 PM kpo: no one is talking about flashing an LED with PC
01:52 PM kpo: this is ineed stupid
01:53 PM kpo: *indeed
01:53 PM thardin: no1curr pretty much
01:55 PM thardin: now js on a micro on the other hand
01:55 PM kpo: and maxing out 8bit micro in C to achieve 10% speedup, when you can just change it for something 10 cents more expensive, but incredibly more capable probably won't be economically justified, unless making 1M+ production
01:55 PM thardin: is something i hear ppl do
01:56 PM rue_shop3: https://images-cdn.9gag.com/photo/aNZKWV0_700b.jpg
01:56 PM rue_shop3: its about suitability for the task
01:56 PM kpo: sure
01:57 PM kpo: but getting things out in the field is just first step
01:57 PM kpo: maintainability is second
01:57 PM rue_shop3: nobody maintains anything
01:57 PM rue_shop3: if it works for a year it'll last till the person throws it out
01:57 PM kpo: i don't know what world you live in
01:57 PM kpo: im talking rather about professional grade instruments for example
01:57 PM rue_shop3: the one where people use a 4Ghz computer with 8 core and 4G of ram to flash an led
01:58 PM kpo: xD
01:58 PM rue_shop3: and people buy things and throw them out after a year
01:58 PM rue_shop3: nomatter what it is
01:58 PM kpo: and do they sell it?
01:58 PM kpo: i mean those supercomputers iwth an led
01:59 PM rue_shop3: nobody who makes anything cares anymore, cause if the customer complains it dosn't work, they were so cheap to make, they can just be sent another one
01:59 PM rue_shop3: and if it takes a year to send them another one, the new model is out and you circumvent the problem
01:59 PM rue_shop3: yes they do sell it
01:59 PM kpo: and in the world of 1 year lifetime products, creating next generation as fast as posiible is desirable feature
02:00 PM rue_shop3: it was so cheap to use that stuff to make the product that nobody cares
02:00 PM nuxil: hmm, here is something interesting
02:00 PM kpo: so again, code faster = more money
02:00 PM nuxil: uint8_t foo(uint8_t x, uint8_t y, uint8_t z) {return x-y+z;}
02:00 PM nuxil: uint8_t foo(uint8_t x, uint8_t y, uint8_t z) {return x+y-z;}
02:00 PM nuxil: "sub" happens before the "add" in both cases
02:00 PM rue_shop3: yea, so copy and paste crap code and push it to marketing
02:00 PM kpo: no
02:01 PM kpo: refactor the code, tell marketing you needed to rewrite part of it because of something, and have great library of maintainable code
02:01 PM kpo: Do you thing that libraries are bad thing?
02:01 PM thardin: I just dont get the gripe here
02:04 PM kpo: rue_shop3: doesn't C allow you to copy and paste code anyway? And C++ was designed to be spectacularly more sustainable/expandable than C
02:05 PM kpo: thardin: I think I don't get it neither ;p
02:06 PM rue_shop3: [12:05] <kpo> thardin: I think I don't get it neither ;p
02:06 PM rue_shop3: I need lunch...
02:06 PM dev1990: I wrote before about some features that are C++ that C should have, and recent C++ releases comes with features like this
02:06 PM dev1990: im talking rather about professional grade instruments for example
02:06 PM dev1990: pff
02:07 PM dev1990: http://wklej.org/hash/1542f7a91ce/
02:07 PM thardin: i'm requesting numbers to back up this c++ griping
02:07 PM dev1990: sorry for that random copy paste..
02:07 PM dev1990: [19:37] <dev1990> value is calculated at compile time with guarantee
02:07 PM dev1990: [19:38] <dev1990> bar and ret don't have even address in memory
02:07 PM dev1990: [19:39] <dev1990> should stay that way even with optimalization turn out
02:07 PM dev1990: [19:39] <dev1990> turn off*
02:07 PM dev1990: more of those features comming
02:08 PM dev1990: even it's now possible to create C compiler at compile time of C++ program
02:08 PM dev1990: https://github.com/kw-udon/constexpr-8cc
02:09 PM dev1990: this is why John Turner was so successful with programming in C++17 at 6502
02:10 PM thardin: -_-
02:10 PM nuxil: auto is soo ugly :p
02:10 PM dev1990: wow
02:11 PM dev1990: auto means your right side of type, why this is ugly ?
02:11 PM thardin: i'm getting too old to keep up with new c++ features. it's fascinating what ppl do with it tho
02:12 PM nuxil: dev1990, why you need auto. you should know what type your assigning your vars :p yes. c and c++ both has it. i just dont like it.
02:13 PM kpo: thardin: not too old, maybe just lazy :D but neither I am at the C++17 level, C++11 and 14 mostly. The new stuff just overwhelms me ;p
02:15 PM dev1990: nuxil: you can avoid implicit converstions, you never leave uninitialized variable, you don't need to change types when you have outgoing refactor on types
02:15 PM dev1990: and many other
02:17 PM nuxil: auto is more confusing than usefull imo, constexpr auto foo(u8 x, u8 y) vs uint8_t foo(blah) is more clear on what it returns.
02:18 PM dev1990: there is also dectype(auto) but this is when you want to copy constness and & for example
02:18 PM thardin: kpo: lazy works too :]
02:19 PM dev1990: nuxil: mayby because it's new, when it's something new then time and research is needed
02:20 PM dev1990: first time when I heard about auto I don't like it
02:20 PM dev1990: but I was probably brainwashed by books and presentation on cppcon
02:20 PM dev1990: but in the end I can use this like fancy lightsaber
02:21 PM dev1990: do stuff in metaprogramming and etc
02:21 PM nuxil: besides auto is "useless" in C its just leftover crap from B that where needed when they ported code :p
02:22 PM dev1990: in C++ you're not forced to you it
02:24 PM dev1990: nuxil: http://wklej.org/hash/55dc606e4b4/ upgrade
02:25 PM nuxil: dev1990, expand on your test.
02:25 PM nuxil: uint32_t bar = 0xabcdef; DDRB = foo(bar >> 16, bar >> 8, bar & 0xff);
02:26 PM nuxil: then do the functions as i posted and see if you get sub done 1st in both cases :p
02:26 PM dev1990: u want to do variadic foo ?
02:26 PM nuxil: uint8_t foo(uint8_t x, uint8_t y, uint8_t z) {return x+y-z;} & uint8_t foo(uint8_t x, uint8_t y, uint8_t z) {return x-y+z;}
02:27 PM dev1990: I'm not testing exacly
02:27 PM dev1990: even
02:30 PM rue_mohr: #define foo((x),(y),(z)) ((x)+(y)-(z))
02:31 PM rue_mohr: INLINE
02:31 PM rue_mohr: yaaaaay
02:31 PM rue_mohr: I just optimized out 10 pushes, 10 pops, and 8 other lines of lookup code
02:32 PM dev1990: and write plain function for that example
02:32 PM dev1990: this is trivial to deduce on callside
02:32 PM dev1990: compiler will do job
02:33 PM dev1990: with that define in corner case you can mislead compiler and generate to much inlined code that can slow computation
02:48 PM polprog: wklej.org
02:48 PM polprog: that's a site i havent seen in a loong time
02:50 PM Ameisen: When I am in an interrupt that was scheduled to run at a fixed rate, which is going to change it's rate (driving a stepper motor at variable rates)... how do I make sure that another interrupt for it doesn't get queued to run immediately after the interrupt returns before I do anything like changing the rate?
02:51 PM Ameisen: That is, I don't want the interrupt to be queued to hit again before the interrupt returns, as it would no longer be valid
02:51 PM Ameisen: do I just disable the timer?
02:51 PM polprog: id give it a try. sounds like it could work
02:51 PM polprog: ind of like a mutex
03:00 PM Ameisen: https://pastebin.com/z8Ntxs10
03:00 PM Ameisen: that should work maybe?
03:55 PM cehteh: Ameisen: interrupts RTFM, dont disable timer, but use the correct waveform/pwm mode
03:57 PM polprog: rue_mohr: instead of a macro, could you use inline [type] foo() {...}
04:02 PM polprog: where is the border between c and c++. is there any?
04:16 PM Ameisen: I have no idea what that question means
04:16 PM Ameisen: C++ is incredibly more powerful than C and is far more featureful. It also requires a lot more skill and knowledge to use effectively as a result.
04:17 PM polprog: im just curios how it has appeared
04:17 PM polprog: did they write it from scratch?
04:17 PM Ameisen: It was originally a C extension
04:17 PM Ameisen: cfront
04:18 PM polprog: okay, that's what i wanted to know :)
04:35 PM polprog: night
04:35 PM dev1990: It is worth a note that C++11 is very different beast in contradiction with C++98
04:35 PM thardin: to be fair you have to have a very high IQ to understand C++11
04:36 PM dev1990: probably all people that know how to connect irc have required IQ
04:36 PM thardin: the syntax is extremely subtle, and without a solid grasp of SINFAE most of the code will go over a typical programmer's head
04:37 PM thardin: there is also stroustrup's nihilistic outlook, which yadda yadda you all know this
04:38 PM dev1990: you mean SFINAE ?
04:38 PM dev1990: with C++17 you can read of most SFINAE by using if constexpr statment
04:38 PM dev1990: s/read/get rid of
04:39 PM dev1990: but well SFINAE is something that many of C++ don't even know
04:40 PM thardin: guy it's a meme
04:40 PM dev1990: ;D
04:41 PM dev1990: but fit perfectly, look http://en.cppreference.com/w/cpp/language/sfinae hahaha
04:42 PM thardin: imagine what we could do without that awkward syntax
05:20 PM nuxil: rue_mohr, nice. macros ftw or what :p
05:23 PM nuxil: my question is. why use c++ when writing code for your typical "avr" mcu thats only a few KB at max. you will never need much of the stuff it offers since your mostly doing verry low lvl stuff.
05:24 PM polprog: sometimes objecta are useful
05:25 PM polprog: objects*
05:25 PM nuxil: give me a good example where you need to create a such program for you mcu that you need it ?
05:26 PM polprog: dunno, simple game?
05:26 PM polprog: im not a fan of cpp on micros
05:26 PM nuxil: then asm is what you want on your mcu :p
05:29 PM nuxil: yea. as i compared it earlier. if need a micro plane to get from A to B. Why use a big ass boeing or some airbuss :p
05:30 PM nuxil: but hey. if it floats your boat. im not gonna stop people from using it.
05:31 PM Jartza: asm is fun
05:31 PM dev1990: yup
05:31 PM Jartza: even attiny can do some fun stuff with asm
05:32 PM Jartza: attinies, I guess that's the plural :)
05:33 PM Jartza: ...like VGA with 32 bytes of ram and 512 bytes of flash with 6-pin mcu ;)
05:34 PM nuxil: yup. amazing
05:34 PM dev1990: nuxil: as kpo told earlier you're paying for what you're using, so features like constexpr, templates, static_asserts and many other can be achived at zero cost, u don't even need to link c++ library for them
05:37 PM nuxil: dev1990, you missing my point entierly.
05:38 PM dev1990: nuxil: so you mean by C++ a project designed with OOP or what ?
05:38 PM kpo: hey, the most obvious example - reprap firmware
05:38 PM nuxil: i just need a language to program my mcu. and i can select from well (asm, C, and C++). since i dont need 99% of the stuff in C++. why bother with it at all. ? the only time i need a language like C/C++ when when i do my Mcu. i am never gonna code some app for desktop or any other systems.
05:40 PM nuxil: i dont care about all the features in C++ when i have no need for them :p
05:40 PM dev1990: heh
05:40 PM dev1990: those C features
05:40 PM dev1990: but introduced in C++ and this is problem
05:41 PM kpo: cpp gives you oop out of the box, without the need for struct object-like hoaxes for example
05:42 PM kpo: I suppose, that if marlin was written in C, it wouldn't draw so many developers
05:44 PM kpo: i'm giving example of marlin, mainly because it growed on avr, but now it is ported for example to Cortex
05:44 PM kpo: 35 open pull requests at github right now, last from 30 minutes ago
05:45 PM nuxil: Jartza, is all the code written in asm for your vga thingy?
05:45 PM kpo: show me similarly growing/maintained project written in C :P (except for linux kernel :D )
05:46 PM kpo: well, i shoul add project for avr
05:46 PM nuxil: linus torvals hates C++ btw :p
05:46 PM dev1990: that is true
05:46 PM dev1990: and I'm fan of Torvalds and I love C++
05:47 PM nuxil: that should not compute and result in segfault :p
05:48 PM kpo: well, i can't say im a big fan of Torvalds, but use Linux everyday
05:49 PM kpo: however, most of "higher layers" are in C++ - i mean e.g. window manager (KDE ftw, not gnome ;p)
05:49 PM kpo: well, i should say graphical environment, not window manager to be precise ;p
05:50 PM nuxil: i seen some interviews with him. kind of fuck: you attitute, dont come here and think you are some smartass / "respect is earned not given" and stuff like that. etc.
05:50 PM kpo: anyway, i respect prohibition of c++ in kernel, there were some reasons for it - dev1990 should know better
05:50 PM nuxil: i like that way of thinking :p
05:51 PM dev1990: yeah, I know some of details on that
05:51 PM cehteh: gtk/gnome is/was C only, perhaps now some C++ creeped in
05:51 PM kpo: nuxil: the iconic "fuck you nvidia" : D
05:51 PM Jartza: nuxil: yes, full asm
05:51 PM nuxil: kpo, is basically said in one of his interviews he dont want C++ people codeing the kernel :p
05:51 PM nuxil: Jartza, o.O youre insane
05:51 PM nuxil: :D
05:52 PM Jartza: https://github.com/rakettitiede/octapentaveega/blob/master/vga.asm
05:52 PM Jartza: if you're talking about octapentaveega
05:52 PM Jartza: but that's for attiny85
05:53 PM Jartza: then there is this "little sister", which is just a stupid demo for attiny5
05:53 PM Jartza: I cann that just pentaveega :D
05:53 PM Jartza: call*
05:54 PM kpo: Jartza: awesome job ;)
05:54 PM cehteh: how about a megaveega in C++? :)
05:54 PM cehteh: and i bet, coding that in C++ makes you curse more than doing it in asm
05:54 PM Jartza: haha
05:54 PM nuxil: megavega lol
05:54 PM kpo: :D
05:55 PM Jartza: https://youtu.be/WdBNR0JEDcY
05:55 PM Jartza: that's the attiny5
05:55 PM dev1990: cehteh: https://www.youtube.com/watch?v=zBkNBP00wJE
05:58 PM Jartza: https://drive.google.com/file/d/1uIhPGSjgmhWGsukzZWYIsLaSUeE-XFTz/view?usp=drivesdk
05:58 PM Jartza: the hardware :D
05:59 PM Jartza: that's vga connectoe
05:59 PM nuxil: it needs google login
05:59 PM nuxil: :(
06:00 PM cehteh: Jartza: not deadbug style directly on the connector pins? :)
06:00 PM Jartza: nuxil: reload
06:00 PM cehteh: nuxil: not for me
06:00 PM nuxil: works now
06:00 PM kpo: cehteh: somebody already did this :P https://www.youtube.com/watch?feature=player_embedded&v=g8t3JWZOqwg
06:00 PM Jartza: yeah, enabled view for everyone
06:00 PM nuxil: btw. where do you get your pcb's done ?
06:00 PM kpo: https://code.google.com/archive/p/arduino-vgaout/downloads
06:01 PM Jartza: IC1=attiny5
06:01 PM Jartza: U1=oscillator
06:01 PM kpo: of course, you can squeeze more using ASM ;) anyway, Merry Christmas guys, going to the real world :P
06:02 PM nuxil: merry xmas to you to.
06:04 PM Jartza: sure atmegas can push more out to vga, but not as fun as attiny :)
06:05 PM Jartza: nuxil: mostly hackvana does mt pcbs
06:05 PM Jartza: some test pcbs I etch at home
06:05 PM Jartza: and few protos are milled by my friend
06:06 PM Jartza: http://hackvana.com/guide
06:07 PM nuxil: thx.
06:13 PM Emil: Jartza: what'sthat shop?
06:13 PM Emil: Nevör höörd
06:15 PM Jartza: there's also #hackvana
06:15 PM Jartza: :)
06:16 PM Emil: Jartza: can you tell me more about them?
06:16 PM Jartza: him
06:17 PM Emil: A single guy operation?
06:17 PM Jartza: nice aussie, lives in a boat and gets boards made in real factories
06:17 PM Emil: ah so he's just aggregating
06:17 PM Emil: based where?
06:17 PM Jartza: and nothing beats the communication in english and live support in irc
06:17 PM Emil: What's the price range?
06:18 PM Jartza: boards come from china, but less hassle than communicating with chinese broken english
06:18 PM Jartza: there's some prices in the guide
06:19 PM Jartza: so far all my 15 (?) orders have gone perfectly correct, whereas I tried elecrow twice and they delivered crap both times
06:19 PM Emil: Holy shit
06:19 PM Emil: expensive as fuck
06:19 PM Emil: Jartza: pffft
06:19 PM Emil: You can pay for your premium if you want
06:19 PM Emil: I have no troubles ordering from the chinese
06:19 PM Jartza: sure thing
06:20 PM Jartza: not for everyone for sure
06:20 PM Emil: 5x5cm boards (or smaller): 10 for the price of 5, for USD19.
06:20 PM Emil: 10 Arduino shields for USD26
06:20 PM Emil: 10 of 5x10cm boards for USD34 (5x: USD31)
06:20 PM Emil: 10 of 10x10cm boards for USD39 (5x: USD34)
06:20 PM membiblio: I am unable to use USBasp from Arduino IDE 1.8.5 it says something about com port but I am able to use from avrdude using -c usbasp - any advice?
06:20 PM Emil: This is just robbery:D
06:20 PM Emil: membiblio: installdrivers
06:21 PM Jartza: beats prinel hands down
06:21 PM Emil: >prinel
06:21 PM Jartza: :D
06:21 PM membiblio: Emil that does not help - specifically which drivers?
06:21 PM Emil: >paying for shit at expensive as fuuuck prizes
06:21 PM Emil: also prinel's delivery is shit
06:21 PM Emil: membiblio: "arduino usbasp driver"
06:22 PM Jartza: and their promises
06:22 PM Emil: Prinel is overprized crap imho
06:23 PM Jartza: still waiting for some stuff ordered ages ago and promised few weeks before christmas
06:23 PM Emil: Jartza: wat
06:23 PM Jartza: luckily it's not my money
06:23 PM Emil: Jartza: top kek
06:23 PM Jartza: some programming jigs etc
06:23 PM Emil: Jartza: why not just order from china with fast shipping?
06:23 PM Emil: Or from oshpark
06:23 PM Emil: both arrive in like a week
06:23 PM Emil: actually the chinese are even faster
06:23 PM Emil: and oshpark premium delivery is 50 euros
06:24 PM Jartza: I had to solder 48 tiny wires to 28x32mm board because no jig :(
06:24 PM membiblio: Emil avrdude is the programming component of Arduino IDE - if avrdude works - why do I need another driver?
06:24 PM Emil: ...
06:24 PM Emil: membiblio: hey, if you want to say I'm wrong
06:24 PM Emil: sure
06:24 PM Emil: whatever
06:25 PM Emil: Jartza: but really, can't beat the Chinese
06:25 PM Jartza: sure
06:25 PM Emil: They also have good support nowadays
06:26 PM Jartza: depends :D
06:26 PM Jartza: have to deal with chinese weekly
06:26 PM Emil: Well if you want to be a shit designer and violate design rules clearly laid out and have someone tell you that
06:26 PM Emil: I mean
06:26 PM Emil: sure
06:26 PM Emil: you can pay for it :D
06:26 PM Jartza: again, luckily not my money :D
06:27 PM Emil: Yeah but it's not about whose money it is :D
06:27 PM Jartza: but customers have lot of crap done in china
06:27 PM Jartza: including the whole manufacturing
06:27 PM Emil: Hmm
06:27 PM Jartza: and usually I have no say about where stuff gets made
06:27 PM Emil: I need to find a fab that does like 3-10 pieces cheaply
06:27 PM Emil: (full assembly)
06:27 PM Jartza: as I'm still mostly embedded sw dev
06:28 PM Jartza: what is cheap?
06:28 PM Emil: Have you used some?
06:29 PM Jartza: tagsu was made by alktech.com
06:29 PM Jartza: our friendly southern neighbour, and they speak finnish
06:29 PM Jartza: full assembly was like umm, 3€ per device or so
06:30 PM Jartza: including the case assembly & testing
06:30 PM Emil: how many devices?
06:30 PM Emil: Because that's reasonable
06:30 PM Jartza: latest batch was 250, but they can even do one if you want
06:30 PM Emil: Did you ship the components to them?
06:30 PM Jartza: nope
06:30 PM Emil: You gave a list and they ordered?
06:31 PM Jartza: thwy source themselves from digikey/mouser/et.al.
06:31 PM Emil: nice
06:31 PM Emil: so that 3€
06:31 PM Jartza: 3€ didn't include components though
06:31 PM Emil: yeah
06:31 PM Emil: thought so :D
06:31 PM Emil: how much are the components
06:31 PM Jartza: but pick'nplace, hand soldering display, firmware flashing, testing and case assembly
06:32 PM Jartza: can't remember currently, but too much :D
06:32 PM Jartza: and oh, the displays I did send them, as they are custom ordered
06:32 PM Emil: hmm, if we say that tagsu costs 20-22€, that's like <1€ for the pcb, probably like 30 cents or less, 3€ for the assembly, lets say 10€ for the components
06:33 PM Jartza: probably will get the next batch made there too
06:33 PM Jartza: Emil: the laser cut case, lanyard, audio cable, battery etc. raises the cost
06:33 PM Emil: haha
06:33 PM Emil: yeah
06:34 PM Emil: yeah I can see the budget filling out
06:34 PM Jartza: eventually I made about 3€ profit per device, haha
06:34 PM Emil: oh waet
06:34 PM Emil: you made profit still?
06:34 PM Emil: _nice_
06:34 PM Jartza: but I didn't make it to make profit anyway
06:34 PM Emil: I thought it was like almost zero profit
06:34 PM Jartza: yeah, that was a bit unexpected, haha
06:35 PM Jartza: but well. 400 sold, means about 1200€, minus taxes...
06:35 PM Jartza: I still wouldn't live with that :D
06:35 PM membiblio: Anyone know how to pass -F to avrdude from arduino ide? Holding Shift while downloading showed the error and I do use -F with avrdude directly
06:35 PM Emil: membiblio: which platform?
06:35 PM membiblio: Linux Ubuntu
06:36 PM Emil: ayyy
06:36 PM Emil: should've said that immediately
06:36 PM Emil: I thought you were on Winshit
06:36 PM nuxil: lol dont go the membiblio :p
06:36 PM Emil: emil.fi/avr
06:36 PM nuxil: ubuntu :p meh
06:36 PM Emil: membiblio: grab the hexfile generated
06:37 PM Emil: it will list the location in the output
06:37 PM membiblio: I'm unsure what you are saying what hex file and for what?
06:37 PM Emil: and then just sudo avrdude -c usbasp -p atmega328p -U flash:w:name.hex:i
06:38 PM Emil: you can also -e to erase
06:38 PM membiblio: I added usbasp.program.extra_params=-Pusb -F -v to hardware/arduino/avr/programmers.txt but it does not seem to send the -f
06:38 PM membiblio: -F
06:38 PM Emil: membiblio: just ditch the arduino :D
06:38 PM Emil: Or if you want to use it, grab the hex and use avrdude directly
06:38 PM membiblio: Emil I can use avrdude not a problem - just an issue with Arduino IDE and avrdude
06:38 PM Emil: membiblio: also check permissions
06:39 PM Emil: membiblio: also, arduino does not support programming through the usbasp normally
06:39 PM membiblio: need -F sent from arduino - not anything else
06:39 PM Emil: it will only burn the bootloader and fuses through it if you ask it to
06:39 PM Emil: but to use usbasp as a programmer with arduino ide you need to google a lot more iirc
06:39 PM Emil: Anycase, good night
06:39 PM membiblio: ok thank you Emil good night
06:39 PM Jartza: verkkokauppa.com made probably more profit with tagsu than I did
06:40 PM Jartza: if I remember correctly, 5€ per device :p
07:41 PM membiblio: Why would shift+upload work in arduino ide but just upload does not work?
09:04 PM rue_mohr: use command line and it'll fix your problem
11:58 PM day__ is now known as day