#avr Logs

Dec 16 2017

#avr Calendar

01:33 AM rue_mohr: real coders just need an io pin
01:36 AM Casper: and toggle switches
01:36 AM rue_mohr: grr arrays of 24 toggle switches
01:36 AM rue_mohr: and displays where c meant 0xB
01:37 AM rue_mohr: and z80 machines that run amok and overwrite hours of entries
01:49 AM rue_mohr: #define tgl(port,bit) (port ^= (1<<bit)) // Toggle bit in port
01:49 AM rue_mohr: #define tst(port,bit) (((port)&(1<<(bit)))>>(bit)) // Test bit in port
01:49 AM rue_mohr: from atmel
02:01 AM nuxil: heh
02:01 AM nuxil: motnings
02:01 AM nuxil: *morning
02:15 AM nuxil: rue_mohr, that tst macro
02:16 AM nuxil: wanna explain why its doing a right shift ?
02:23 AM nuxil: i dont get it. if i break it down. example, bit = 2, port = 0b1000, (port) & (1<<(bit)) => 1010 , 1010 >> bit = 0010
02:23 AM nuxil: so how is it doing a test ?
02:52 AM nuxil: besides a marcro like: #define tst ((port & (1<<bit))?1:0) is much clearer to read and understand whats going on :p
02:52 AM Jartza: https://gist.github.com/Jartza/56d006504316ef5fe5a3db1b3e438ca9
02:52 AM Jartza: these are much better ;)
02:53 AM Jartza: #define BUTTON BITP(PORTB, PB2)
02:53 AM Jartza: then BUTTON is either 0 or 1 if you have set that as input
02:55 AM Jartza: oh well. PORTB should be PINB of course if you want that, d'oh
02:58 AM nuxil: nice
03:19 AM Jartza: I've used those macros for long time with avr, you can give meaningful names to pins and use them simply
03:20 AM Jartza: also the BITS_... macros are much more readable than their counterparts
03:20 AM Jartza: BITS_SET(DDRB, PB3, PB5, PB7) => DDRB |= ((1 << PB3) | (1 << PB5) | (1 << PB7))
03:22 AM Jartza: BITS_CLEAR(PORTB, PB0, PB4) => PORTB &= ~((1 << PB0) | (1 << PB4))
04:33 AM polprog: Emil: ive got win7 though
04:48 AM polprog: ok, grabbed services for unix .exe from MSDN and some ISO from some mirror
04:57 AM polprog: damnit doesnt work on 64 bit
06:11 AM mmfood: I am quite new to C and especially pointers. Could any one tell me if this is the correct uses of a pointer https://pastebin.com/4SyjBXdU? I am trying to create a library for use with any number of 595 shift registers.
06:17 AM antto: you're passing an array as a function argument
06:18 AM antto: and you're not using the pointer right
06:18 AM antto: arr[j] gives you the _value_ at index j
06:19 AM antto: if you want the pointer to point to arr[j] then take its address with the & operator
06:19 AM antto: pointer = &(arr[j]);
06:20 AM antto: why not simply change your function to take (const uint8_t* data, const uint8_t size) as arguments?
06:22 AM antto: ooh, and then you're bitshifting the pointer?!
06:26 AM mmfood: my thinking is that I can have an array of uint8_t with the length equal to the number of shift registers. And then shift in each of these in sequence. Putting the first uint8_t in the last shift register. If I would use your example with data and size as arguments then I would I not limit myself to for instance 1 shift register with a uint8_t?
06:26 AM antto: also, when you paste a URL.. don't append a "?" on it.. or any other symbols.. just surround it by whitespaces
06:28 AM mmfood: yes, that obvously didn't work. I thought in essence if a pointer is assigned variable then actions performed upon the pointer would be actually be performed on the variable it is pointing to.
06:28 AM antto: i've my own "library" for dealing with 595 SIPOs and 165 PISOs at work, but it's written in C++ and for the xmega
06:29 AM antto: and there the "number of shift registers in the circuit" is set as a constructor argument
06:29 AM antto: thus i can have two (or more) SIPO lines with different number of chips in each
06:29 AM antto: ..at the same time
06:29 AM mmfood: ok, would that not be analogous to defining a NO_SR value?
06:30 AM antto: and no hardcoded #definitions
06:30 AM antto: what if you need two lines?
06:30 AM antto: it doesn't matter at the end, this really just determines the number of clock/data shifts, and the data size
06:31 AM polprog: antto: so, if i understand this right, int[10] arr; int* a = &(arr[2]); is correct?
06:31 AM mmfood: hmm, yes that wouldn't work. But atm I am only using them in series
06:32 AM antto: polprog int[10] ?!
06:32 AM antto: not sure what that'll do
06:32 AM polprog: just an example, 10-element array, is it?
06:33 AM polprog: mmm... int arr[10];
06:33 AM antto: well, i normally declare arrays like so: uint8_t arr[10];
06:33 AM polprog: yeah, that way
06:33 AM polprog: with dynamic memory, that would be uint8_t* arr = malloc(10);
06:33 AM polprog: right?
06:33 AM antto: yes, and now if you want to operate on your pointer as if you're operating on the pointed-to element, use the * operator
06:34 AM polprog: so for example *a = 15; that would make arr[2] = 15 ?
06:34 AM antto: i've not really used C dynamic memory, i come from C++
06:34 AM antto: so i use new/delete
06:34 AM polprog: i come from java so that's even more difficult to me :P
06:34 AM antto: yeah
06:35 AM polprog: what was a kind of a shock or disappointment for me when i started to learn C several years ago was that there is no array.length like in java
06:35 AM antto: uint8_t *ptr = array[index]; *ptr = 0xFF; // modify the element
06:36 AM polprog: not &(array[index]) ?
06:36 AM antto: for static-sized arrays (those who the compiler is aware of) there is sizeof() .. sorta
06:36 AM antto: why did you jump to C and not C++ ?
06:36 AM mmfood: antto: how is C++ compared to C when used with AVR?
06:37 AM antto: mmfood i find encapsulation vital for me, otherwise i tend to make a big mess of global-scope crap ;]
06:37 AM polprog: antto: for some time i was programming in C being unaware that it's cpp. used cout and cin when i was doing competition submissions.
06:37 AM antto: it is especially nice on xmegas, which are more structured than other AVRs
06:37 AM polprog: still im now compiling with gcc vs g++
06:37 AM polprog: recently im trying c++
06:38 AM polprog: so basicaly not mixing printf and cout lol
06:38 AM antto: i mix em
06:38 AM antto: but i really really like objects
06:38 AM polprog: im trying to learn classes in cpp
06:38 AM antto: like in my PISO/SIPO "library"
06:38 AM polprog: piso/sipo?
06:39 AM antto: Paralel In, Serial Out (165), Serial In, Parallel Out (595)
06:39 AM polprog: ah
06:40 AM antto: AS_SIPO_t led_sipo(pins.., size);
06:40 AM antto: that's how it looks like, sorta
06:40 AM antto: led_sipo.shift();
06:40 AM antto: ehm, that shifts the whole data
06:41 AM mmfood: ffs, a third device is now bricked for unknown reasons
06:42 AM antto: in xmega, the constructor takes pointers to the pins (objects too) related to the SIPO
06:42 AM mmfood: they work for for a bit and then suddenly the programmer can't read the "RDY / nBSY pin" for some reason and the fusees are all messed up
06:42 AM antto: what programmer is that?
06:42 AM mmfood: avr isp
06:43 AM mmfood: mkII
06:43 AM antto: uh.. is this atmel studio?
06:43 AM mmfood: nope, avrdude
06:43 AM mmfood: from a makefile
06:43 AM antto: are you frying them? is your circuit doing something?
06:45 AM mmfood: Something is doing something
06:48 AM mmfood: I am using the MISO/MOSI/SCK pins for buttons as well so they have 10k pullups. Is that a bad thing?
06:57 AM antto: pressing them would probably be bad if the pin is an output (or connected to some other output)
06:57 AM antto: use internal pullup resistors if you can
06:58 AM mmfood: I an not pressing them
06:59 AM antto: no idea then
07:04 AM mmfood: maybe it is just me being clumsy and sloppy when not disconnecting power before rearranging connections
07:06 AM mmfood: took a chance and put another mcu in. Hopefully it will survive :)
07:07 AM mmfood: Anyways, the code is working if I am using uint8_t data = arr[j], ie no pointers.
07:08 AM antto: "arr" is a pointer ;P~
07:08 AM mmfood: it is?
07:08 AM antto: yeah
07:08 AM mmfood: since it is an array or since it is an argument?
07:09 AM antto: it points to the beginning of the array
07:09 AM antto: if you do *arr you'd get the value of the first element
07:09 AM mmfood: my programming frequency is way to low for remembering this stuff :)
07:09 AM mmfood: oh, right
07:10 AM mmfood: saw a computerphile on that
07:10 AM antto: you could also do.. uint8_t *ptr = arr; ptr[3] = 0xFF;
07:11 AM mmfood: isn't it the same with any variable though? it points to the beginning of the variable. So if char bits = 0b00000001, bits is pointing to the beginning of 0b000000001?
07:12 AM antto: well, i wouldn't say that
07:13 AM antto: you can take the address of the variable "bits" and then pretend it is a pointer to an array
07:13 AM antto: but you'd better know what you're doing then
07:14 AM antto: if "bits" is a local variable, then its address could be different every time (afaik)
07:14 AM antto: also, it will stop existing when it goes out of scope
07:15 AM antto: thus there might be something different at that memory address
07:22 AM antto: hm.. "low power crystal" or "full-swing crystal" ?!
07:22 AM mmfood: antto: well, sure. But then we are not talking about the same variable anymore I guess, since we are in a different scope. But if we are talking in the lifetime of that variable :)
07:22 AM antto: sure, you can take its address
07:23 AM antto: just be careful ;P~
07:35 AM polprog: antto: recently im trying general C++, downloaded dev cpp (so i can send screenshots to classmates - we use is in programming classes) and im trying to implement a simple physics engine
07:35 AM polprog: waht i want at the end is a dot bouncing on the screen
07:35 AM polprog: :P
07:35 AM polprog: dev CCCP
07:36 AM antto: dev cpp? screenshots?
07:36 AM polprog: Dev-C++
07:36 AM antto: *shrug*
07:36 AM antto: i'm using my normal IDE and gcc
07:36 AM polprog: yeah, im on windows.
07:36 AM polprog: usually i'd just open any text editor and write a makefile
07:36 AM antto: ..on both windows and linux
07:37 AM antto: Makefile :~(
07:37 AM polprog: whatever, this works...
07:37 AM antto: mine works too
07:39 AM antto: my C++11 FIFO attempt: https://i.imgur.com/AkGsfPH.png
07:42 AM antto: or more like, buffered interrupt-driven usart
07:43 AM antto: i need to learn this template metaprogramming black magic, it seems powerful
07:44 AM polprog: codeblocks
07:45 AM polprog: well, similar to what im using right now
07:45 AM antto: all IDEs look similar
07:45 AM polprog: nice DE
07:45 AM antto: codeblocks is not married to a compiler
07:46 AM polprog: for big avr projects i use eclipse and for small vim or emacs
07:46 AM polprog: brb
07:47 AM antto: i only use this IDE for everything from avr/pic to desktop apps and sh*t
07:48 AM antto: with a range of compilers
07:48 AM antto: no makefiles
07:49 AM antto: except for a few projects, and i still build them from the IDE (which executes the makefile)
07:53 AM polprog: https://puu.sh/yHEcc/1a4f511b2a.png
08:02 AM randoh: o/
08:02 AM randoh: I could use a second set of eyes here...
08:02 AM randoh: Trying to multiplex 2 rgb led's on 2 74595's
08:02 AM randoh: https://pastebin.com/JxRKY9M1
08:02 AM randoh: the darn thing is working, but the leds are nowere near full brightness
08:02 AM randoh: and I can see them flicker.. what timings do I need?
08:02 AM randoh: for proper lit leds
08:04 AM polprog: calcuate total time of one loop iteration and you get the multiplex freq
08:04 AM polprog: also, how are they connected?
08:05 AM polprog: antto: what kind of DE/distro was that?
08:07 AM randoh: polprog: common anode columns
08:07 AM randoh: rgb rows
08:07 AM randoh: one 595 for rows, one for the columns
08:11 AM randoh: polprog: easiest way to do said calculaton would be?
08:15 AM polprog: randoh: since there are no delays in the shift function, then it's 6ms moreless
08:15 AM polprog: 1/6ms ~= 166Hz
08:17 AM polprog: odd, that should not be visible.
08:21 AM randoh: 6ms into the delays?
08:21 AM randoh: very much visible and dim
08:25 AM antto: polprog debian9, lxde, with xfce4-panel and some other tweaks
08:26 AM polprog: no, i said that the loop takes 6 ms for each execution
08:28 AM randoh: oh
08:31 AM randoh: soo. what delay then?
08:42 AM randoh: ?
08:48 AM antto: a 50Hz blink is visible iirc
08:56 AM Tom_L: barely
09:00 AM antto: tell that to my cat
09:10 AM randoh: 1ms delay is solid and dim.. damn
09:10 AM randoh: solid-ish*
09:15 AM randoh: .5VDC
09:15 AM randoh: I'm not surprised it's dim
09:18 AM antto: uh
09:19 AM antto: i can't seem to program my atmega48PA, avrdude reads its signature bytes as 0x68xxxx where those last ones are random every time
09:19 AM antto: ..using my "stk200" parallel port
09:21 AM antto: uh, actually, the same thing happens even when the ISP cable is disconnected.. dafuq
09:23 AM * randoh is still confused
09:57 AM randoh: soo noone knows? mkay then
10:35 AM randoh: Also, if it matters, I'm using the internal oscillator
10:43 AM Casper: multiplex will dim the leds, you can mitigate that by overdriving. check the led datasheet to know by how much you can. Take note that it will reduce the lfe of the led
10:44 AM Casper: or... not...
10:44 AM Casper: hmm
10:45 AM randoh: ah, so I'm better off with some drivers than a 595?
10:45 AM randoh: or can I achieve good results with 595's too? I've seen stuff on the internet...
10:45 AM Casper: if you are alternating between the leds, you get dimming since it go on and off
10:46 AM Casper: also, the chip have a 70mA limit per chip, which may cause some small current issues if you have many leds
10:48 AM randoh: hmmph
10:50 AM randoh: well, its done on Youtube so it can be done...
11:07 AM randoh: the only problem is how
11:24 AM polprog: there are many many many factors that the light quality depends on
11:28 AM randoh: well, now I have a solid dim light atleast
11:28 AM randoh: so that's something
11:38 AM antto: oh duh, the ISP adapter i made was not making contact with the reset pin x_x
11:48 AM randoh: And it's dim because of the multiplexing, not because of the power, so it's a code problem, I know that...
11:49 AM randoh: god dammit me, can't even get 2 leds to light up diagonally
11:49 AM randoh: in a visible amount of light
11:49 AM rue_bed: antto, try setting the 'slow' flag in avrdude and see if you get the same errors
11:50 AM rue_bed: randoh, for drivingwhat?
11:51 AM rue_bed: randoh, duty of the leds
11:51 AM rue_bed: turn them on, delay for a tiny bit, then swtich
11:51 AM randoh: I have a test 2x2 rgb matrix, I want to get multiplexing to work
11:51 AM rue_bed: how did ya configure it?
11:51 AM randoh: well, https://pastebin.com/TnF9JqTP does just that. Result is extremely dim leds
11:52 AM randoh: shiftOut for columns, shiftOutRGB to the row RGB pins
11:52 AM randoh: common anode
11:52 AM rue_bed: WTF
11:52 AM rue_bed: randoh, see the topic!?!?!
11:53 AM rue_bed: those are macros for setting and clearing a bit TO MAKE CODE READABLE
11:53 AM rue_bed: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGG
11:54 AM randoh: :D
11:54 AM antto: rue_bed nonono, no errors now.. but avrdude doesn't know the m48PA chip, so i'm telling it it's a m48p
11:54 AM rue_bed: randoh, use the freaking macro for set and clear so I can read your code
11:55 AM rue_bed: from wat I can tell, its not multiplexed, its just serial access
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:55 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:56 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:56 AM rue_bed: USE THE FREAKING BIT SET AND CLEAR MACROS TO MAKE YOUR CODE READABLE PEOPLE
11:56 AM rue_bed: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
11:59 AM cehteh: someone forgot to take his pills
12:00 PM randoh: jeezh, this place is hostile... https://pastebin.com/C5vprxvQ
12:02 PM randoh: is that better ^ rue_bed
12:05 PM LeoNerd: I tend to prefer e.g PORTB |= _BV(PB4);
12:10 PM antto: rue_bed o_O
12:30 PM randoh: rue_bed:
12:30 PM randoh: rue_bed:
12:30 PM randoh: rue_bed:
12:35 PM rue_mohr: #define sbi(port,bit) (port |= (1<<bit)) // Set bit in port
12:35 PM rue_mohr: #define cbi(port,bit) (port &= ~(1<<bit)) // Clear bit in port
12:35 PM rue_mohr: ^^ that is RIGHT out of an app note from atmel
12:36 PM rue_mohr: even they know how to do it
12:36 PM cehteh: these macros are marked obsolete :D
12:36 PM rue_mohr: only by name
12:36 PM rue_mohr: you should still use functions or macros to make your code readable
12:36 PM rue_mohr: write a function for setting and clearing a bit if you want
12:37 PM rue_mohr: people dont seem to care that a macro istrinsically inline anyhow
12:37 PM rue_mohr: its just going to drive me crazy
12:38 PM rue_mohr: PORTC &= ~(1<< rgbshift_clock); is NOT as legible as clearBit(PORTC, rgbshift_clock)
12:38 PM rue_mohr: AAAAAAAAAAAANNNNNNNDDDD
12:39 PM rue_mohr: you people can even take it a step further!!!!!
12:39 PM rue_mohr: rgbshift_clock_low();
12:39 PM rue_mohr: wow, like wow
12:39 PM rue_mohr: you can build macros to just make your code READABLE
12:40 PM rue_mohr: its beyond me why PEOPLE JUST DONT GET IT
12:46 PM randoh: yeahyeah, working first, clean later
12:47 PM randoh: in this case
12:47 PM randoh: in any other case - flip that order straight around
12:53 PM randoh: And in this case, it doesn't work properly
12:58 PM randoh: k
12:58 PM randoh: switched to a 1us delay
12:58 PM randoh: and it's noticeably brighter
12:59 PM randoh: but not enough
12:59 PM twnqx: rue_bed: those macros suck, and i would absolutely not trust the compiler to turn multiple bit settings at once into a single instruction.
12:59 PM randoh: visibly does not mix to white, for example
01:22 PM randoh: rue_bed: has nothing smarter to say, I see
01:50 PM Emil: rue_mohr: rue_bed perhaps you should take a vacation
01:51 PM antto: atmega48PA datasheet says that, to toggle a pin, you can write 1 to the PIN register
01:52 PM antto: is that something new in atmegas?
01:52 PM Emil: no
01:52 PM Emil: been that way for years
01:52 PM Emil: most megas support it iirc
01:57 PM antto: either something isn't working, or the programmer is holding the chip in reset?!
01:57 PM antto: ah, it's the programmer :/
02:57 PM nuxil: thats right. blame the programmer, "your self" :p
04:22 PM fooman2011: Hello. To create a mounting holes in KiCad, I first add a pad. Then I set its properties: Type: NPTH, SizeX: 3, Drill SizeX: 3, Layers: F.SlikS, F.Mask, B.Mask, Dwgs.User. It seems to be ok but when I edit the pad and try to change the value of Position X, only one part of the pad is moved. Could you please tell me how to fix this problem ?
04:22 PM polprog: why do you make pads?
04:23 PM polprog: i juat set grid to mm-based one and use the circle tool to make one on edge.cuts layer
04:24 PM polprog: if i need grounding i then make a zone on f.mask and b.mask layer
04:24 PM fooman2011: Ok I try this
04:25 PM fooman2011: There is no radius on circle in this tool
04:25 PM fooman2011: what pointX and pointY for a circle ?
04:25 PM polprog: thats why i mentioned the grid settings
04:26 PM fooman2011: But if I need to place a circle perfeclty, I change the value from the edit box
04:26 PM fooman2011: I don't have any info here
04:27 PM polprog: in that case the pad approach might be better
04:27 PM fooman2011: :/
04:53 PM fooman2011: polprog: I have another problem. In this video https://www.youtube.com/watch?v=cvqkVT23mcc you can see the guy starting autorouter from context menu. I tried this yesterday and that works. But today I don't have the "Autoroute" item in the context menu anymore. Any idea where this problem comes from ?
05:10 PM rue_mohr: you should convolute all your code then
05:10 PM rue_mohr: make sure one of it is readable
05:10 PM rue_mohr: that will help you avoid bugs AND get ya lots of help
05:10 PM rue_mohr: atg
05:10 PM rue_mohr: arg
05:10 PM rue_mohr: I dont mean to be a guy who isn't trying to help
05:11 PM fooman2011: ?
05:11 PM rue_mohr: why cant people just use a macro (or to hell with it write a god damned function) to set and clear bits
05:11 PM rue_mohr: the macro works, half the people insist its satan and the other half dont use it, we dont know why
05:12 PM rue_mohr: the macro has always worked
05:13 PM rue_mohr: I'm tired of trying to decipher what peoples code is doing with bits while I'm trying to find their bug
05:13 PM rue_mohr: maybe I should just rewrite the code for them
05:13 PM Emil: polprog: I actually prefer using throughholes for mounting holes
05:13 PM Emil: because you get through hole plating
05:13 PM fooman2011: hi Emil
05:13 PM Emil: fooman2011: hi
05:13 PM rue_mohr: I mean, if people cant even grasp using a set and clear macro, they will NEVER grasp making macros named for what they are actaully doing
05:13 PM LeoNerd: To be honest, the thing I find most annoying about other people's AVR code is they do bit-twiddling *at all* on any peripheral config register, out in mainline code
05:14 PM fooman2011: do you know why autorouter has disapear from my kicad ?
05:14 PM Emil: fooman2011: kicad does not have an autorouter by default
05:14 PM LeoNerd: As if I'm supposed to remember whether WG01 is supposed to live in TCR1A or TCR1B
05:14 PM Emil: you need to install it manually
05:14 PM LeoNerd: and what it does
05:14 PM LeoNerd: Exactly *how* folks set those bits I don't mind at all
05:14 PM LeoNerd: The main problem I have with SetBit and ClearBit as defined in /topic is that they *ONLY* work for single bits, not multiple
05:14 PM Emil: LeoNerd: a) it's TCCRIx and b) it's in both
05:14 PM Emil: oh WG01
05:15 PM Emil: that's in TCCR1A iirc
05:15 PM LeoNerd: E.g. you can't atomically twiddle multiple bits at once with those
05:15 PM LeoNerd: So people have to write different things *anyway*
05:15 PM rue_mohr: macros that use more than one command DO need to be used with caution, you cant just stick them on an unbraced if
05:15 PM LeoNerd: Whereas, using the PORTB |= _BV(PB2); style, it's trivial to just extend to PORTB |= _BV(PB2)|_BV(PD3);
05:15 PM Emil: REGISTER OPERATION VALUE
05:15 PM Emil: is prefererd over
05:16 PM rue_mohr: LeoNerd, yes, but people ARE ONLY SETTING ONE BIT with them
05:16 PM Emil: sbi(something ,something)
05:16 PM LeoNerd: And honestly, it takes about 10 minutes of training your eye, and then you can just see that PORT |= _BV(BIT) is just SetBit(BIT, PORT)
05:16 PM tpw_rules: rue_bed: that's you enclose them in a do { <stuff>} while (0);
05:16 PM LeoNerd: It's about the same amount of typing
05:16 PM tpw_rules: in the macro defintiion
05:16 PM rue_mohr: I HAVE NEVER scorned someone for code that set more than one bit at a time
05:16 PM Emil: wait wat
05:16 PM LeoNerd: rue_mohr: so people should write /fundamentally different/ code when setting one bit, or more than one?
05:16 PM rue_mohr: you dont need to put them in braces with a while zero thats just crap
05:16 PM Emil: what is the argument
05:16 PM fooman2011: Emil: did you see the youtube video linked I send here ?
05:17 PM Emil: fooman2011: not yet
05:17 PM fooman2011: Kicad has one autorouter now (it seems)
05:17 PM rue_mohr: no, people are going around setting and clearing ONE bit with a whole bunch of obfiscating code
05:17 PM fooman2011: In this video https://www.youtube.com/watch?v=cvqkVT23mcc you can see the guy starting autorouter from context menu. I tried this yesterday and that works. But today I don't have the "Autoroute" item in the context menu anymore. Any idea where this problem comes from ?
05:17 PM tpw_rules: rue_mohr: ??? it turns a multi-statement if into a single statement
05:17 PM Emil: fooman2011: oooh interesting
05:17 PM Emil: though I would rarely use it :D
05:17 PM tpw_rules: fooman2011: is it the graphics mode you have selected
05:17 PM tpw_rules: try selecting default or opengl
05:17 PM Emil: tpw_rules: probably
05:17 PM Emil: fooman2011: select opengl
05:17 PM tpw_rules: it might only be on one
05:17 PM Emil: tpw_rules: it's probably not in default
05:18 PM Emil: default, is like, not really developed anymore that much iirc
05:18 PM rue_mohr: https://pastebin.com/TnF9JqT
05:18 PM rue_mohr: https://pastebin.com/TnF9JqTP
05:18 PM rue_mohr: sorry
05:18 PM rue_mohr: which of those sets and clears mroe than one bit at a time?
05:18 PM rue_mohr: PORTB |= (1<<data_out);
05:18 PM rue_mohr: not that line
05:18 PM rue_mohr: PORTB &= ~(1<<data_out);
05:18 PM rue_mohr: not that
05:18 PM rue_mohr: PORTB |= (1<< shift_clock);
05:18 PM fooman2011: tpw_rules: where ?
05:18 PM rue_mohr: PORTB &= ~(1<< shift_clock);
05:18 PM rue_mohr: PORTB |= (1<< store_clock);
05:18 PM rue_mohr: PORTB &= ~(1<< store_clock);
05:19 PM rue_mohr: nope I only see one bit changing here
05:19 PM Emil: fooman2011: it's in the second first menu irc
05:19 PM LeoNerd: (ohdear, is someone manually reïmplementing SPI?)
05:19 PM rue_mohr: PORTC |= (1<<rgb_out);
05:19 PM rue_mohr: still only seeing one bit
05:19 PM Emil: DDRB|=((1<<shift_clock)|(1<<store_clock)|(1<<data_out));
05:19 PM rue_mohr: LeoNerd, not my point, the point is that THIS is what annoys me
05:19 PM Emil: what¨'s that?
05:19 PM rue_mohr: thats find
05:19 PM rue_mohr: matter a fact
05:20 PM Emil: anycase what's the bloody argument anyways? :D
05:20 PM fooman2011: second first menu irc ?
05:20 PM rue_mohr: DDRB = (INPUT << PB0 | OUTPUT << PB1 | OUTPUT << PB2 |OUTPUT << PB3 |OUTPUT << PB4 |INPUT << PB5 |INPUT << PB6 |INPUT << PB7);
05:20 PM fooman2011: what is this ?
05:20 PM Emil: fooman2011: https://emil.fi/jako/kuvat/2017-12-17_01-20-02_gRqxCBWU.png
05:20 PM rue_mohr: OOOOOH FUCK i USED A DEFINE
05:20 PM Emil: third first menu
05:20 PM rue_mohr: look, my code is readable
05:20 PM twnqx: the weird "SET_BIT is more readable than setting a bit" argument
05:20 PM Emil: view-menu
05:20 PM rue_mohr: you can tell which bits are input and which are output
05:21 PM Emil: rue_mohr: chill
05:21 PM rue_mohr: but point being, that I'm not scorning anyone for lines like that operatigng on more than oen bit at a time
05:21 PM fooman2011: Ok I tried OpenGL, Cairo, or Default and I don't have the "Autoroute" item in the contextual menu
05:21 PM rue_mohr: Emil, why can nobody get it?
05:21 PM LeoNerd: rue_mohr: I'm not saying you should. I'm saying don't special-case single bits. otherwise you get crap like SetBit(0, PORTB); SetBit(1, PORTB); SetBit(2, PORTB);
05:22 PM twnqx: "it's ok for more than one bit but punishable by death if used for exactly one"
05:22 PM rue_mohr: 99% people only set and clear one bit
05:22 PM twnqx: now that makes your argzument totally void in my books.
05:22 PM rue_mohr: 99%
05:22 PM twnqx: if it's valid in one case, it's valid in all cases. period.
05:22 PM rue_mohr: and they do it PORTB &= ~(1<< store_clock); like that EVERY FFFFFFFFFFFFFFFFFFFFF TIME!
05:22 PM LeoNerd: rue_mohr: you'd probably rant at such a person writing *that*, because surely they should do it in one write. What I'm saying is that if you teach people to do that write by PORTB |= _BV(0); then it becomes much much easier to explain to people that it extends by PORTB |= _BV(0)|_BV(1); than having to say "sorry, the SetBit macro only does one bit, so you'll have to do this *whole new thing* here to set >>
05:22 PM LeoNerd: << multiple bits"
05:22 PM LeoNerd: It is *THAT* principle why I hate your macros
05:23 PM Emil: rue_mohr: you are pulling those stats out of your ass
05:23 PM LeoNerd: They do not teach extensible reuseable principles. They lock people into stupid specialpupose crap like I hate Arduino for
05:23 PM twnqx: also, that whole argument is void, because you can do variadic macros that set any number of bits :P
05:23 PM LeoNerd: twnqx: Sadly I don't think the C preprocessor is powerful enough to expand SetBits(PB1, PB3, PB6, PORTB); correctly
05:23 PM twnqx: it is :P
05:24 PM Emil: Where's lambda_aurigae
05:24 PM LeoNerd: Scheme's macro system is powerful enough for the eqvuialent, but I can't think how to do that in C
05:24 PM Emil: I miss him
05:24 PM rue_mohr: https://pastebin.com/TnF9JqTP <-- did you help them figure out why their matrix scanner dosnt' work?
05:24 PM twnqx: LeoNerd: https://paste.pound-python.org/show/nQLdhMAItAGYyvKoMqmT/
05:24 PM rue_mohr: I couldn't get past the code, too many levels trying to remember what he's doing instead of reading readable code
05:24 PM LeoNerd: twnqx: Ugh, that's cheating. That's 8 different macros, one named per count of bits :P
05:25 PM twnqx: but you only USE the SET_BITS one, the others are internal.
05:25 PM LeoNerd: Oh .. *reads more closely*
05:25 PM rue_mohr: #define DATAlow() ClearBit(DATA, PORTD)
05:25 PM rue_mohr: #define DATAhigh() SetBit(DATA, PORTD)
05:25 PM rue_mohr: #define pulseSCK() SCLKlow(); NOP(); NOP(); SCLKhigh(); NOP()
05:25 PM LeoNerd: Ooooooh
05:25 PM rue_mohr: #define SendOne() DATAhigh(); pulseSCK()
05:25 PM LeoNerd: *giggle* OK I totally take that back... twnqx that *is* cute :)
05:26 PM rue_mohr: for( temp = (0x0001<<15); temp != 0; temp >>= 1) {
05:26 PM rue_mohr: if ( (bits & temp) != 0 ) { SendOne();
05:26 PM rue_mohr: } else { SendZero();
05:26 PM rue_mohr: }
05:26 PM Emil: rue_mohr: stop
05:26 PM fooman2011: ...
05:26 PM fooman2011: it impossible to discuss
05:26 PM Emil: yeah
05:27 PM twnqx: LeoNerd: i wrote that after a more intimate contact with variadic macros than i ever wanted :P
05:27 PM Emil: fooman2011: you could try to ask in #kicad, too. You are using pcbnew and not eeschema, right?
05:27 PM LeoNerd: twnqx: Yeah, that's remarkably inspired actually :) Hopefully, gcc still emits the efficient output for constants?
05:27 PM LeoNerd: I.e. it really is just a LD / OR / ST triplet
05:27 PM twnqx: sure, unless you throw variables in it's all compile time
05:27 PM LeoNerd: Nice
05:28 PM LeoNerd: Ohyes I know it *should* be compiletime, but I've seen gcc fuck up all over the place
05:28 PM LeoNerd: I'm still grumpy that on an ATtiny, x * 2 or x * 4 is done by simple shifting, but x * 3 requires a library call to multiply by constant 3
05:28 PM Emil: LeoNerd: vs?
05:28 PM twnqx: mh, doesn't compile on newer gcc any more, i wrote that 2014
05:29 PM LeoNerd: Emil: If you hand write x + (x * 2) it will notice it can do that with a shift and add
05:29 PM Emil: well, add, add, add is quite quick, too
05:29 PM Emil: add, add*
05:29 PM LeoNerd: If you write x * 3 it won't, and will move x to r16, constant 3 in r17 and then CALL __imul
05:29 PM twnqx: slower than shift, usually
05:29 PM twnqx: lol
05:29 PM Emil: LeoNerd: that's pretty sad
05:29 PM twnqx: not shift+add?
05:29 PM Emil: LeoNerd: which version?
05:29 PM Emil: twnqx: well, actually, two adds is faster
05:30 PM LeoNerd: Emil: it's doubly sad when it does that _implicitly_ for accesses to struct { int x; char y } array[10]; elements
05:30 PM rue_mohr: :/ they dont optimize constant multiplication?
05:30 PM LeoNerd: Because array[i] internally requires calculating i * 3
05:30 PM twnqx: Emil: ok, in x86 you use some adressing mode where you can shift+add in one
05:30 PM LeoNerd: Last time I looked, gcc can only optimise multiplication by constant powers of 2
05:30 PM rue_mohr: Y = A<<1+A;
05:30 PM Emil: twnqx: hmm, now that I think about it, it's actually the same with avr imho
05:31 PM twnqx: no, i don't think so
05:31 PM rue_mohr: Y = ((A<<1)+A);
05:31 PM Emil: twnqx: or wait, there might be some multiply and accumulate with avrs, too
05:31 PM Emil: twnqx: no I mean shift, add is same cucles as add, add
05:31 PM twnqx: true
05:31 PM twnqx: i know that gcc on x86 optimizes it, but i rarely disassemble avr programs to read the output
05:32 PM rue_mohr: I have a few times, some of the stuff surprised me
05:32 PM rue_mohr: like that setbit and clearbit macro being turned into a sbi and cbi instruction
05:32 PM rue_mohr: didn't think it could really read that far into it
05:34 PM rue_mohr: ugh, I'm supposed to get a tree today
11:07 PM day__ is now known as daey