Pan Tilt Hat Motion Eye OS action buttons

I finally got some sense of how to define preset-buttons . Attached screengrab of up-down left-right and preset 1 2 3

My up left and right buttons are basically presets. Pressing one of them moves my pan tilt to a specific position. Up has it look straight out and slightly down at my driveway. Right has it pan to the right to look at my front yard. etc. I could have used 1,2,3 but the arrows work better for me.
I didn’t bother doing the pan left right up down incrementally with a button press. It’s not something I need with what I’m doing. And that appears to be the really tricky bit.

Yes I agree, I am slightly confused about how to get up-down-left-right stepping the servos incrementally. I thought basically that was the meaning. As far as I understand pantilthat.pan(x) and pantilthat.tilt(y) x and y are degrees from center positions. So actually up-down-left-right .py files are more or less presets. So needs more studies indeed… Anyhow quite interesting exercise

I “think” this is the pan tilt by increments code. I haven’t got a clue as to how it does it to be honest.

Tweaked mine slightly today I changed my Left, Up, Right buttons to presets 1 2 3. All I had to do was rename the files, left_1 became preset1_1. I didn’t like the onscreen arrangement of the buttons. For me it was up, left, right. Now its the equivalent of left, up, right. up for me is my center / forward view.

The script above works. I tried it on a clean ME install and it ran like a charm. I SSH’d into the Pi and dropped the whole script in and the buttons are there. I turned off still snapshots and the buttons are all nicely aligned. I’m quite happy.

The last link I posted? Does it pan tilt while the button is pressed? What I mean is, does it move in the direction clicked, and keep moving in that direction as long as the button is clicked? Or just move so far?

This one.

No it moves in increments. One per button press. There’s no way to slow pan for example.

I’m guessing that the line in each command:

newPos = currentPos - 20

would be the one to modify the incremental movements.

Ok, thats good info to know. Thanks for the post back.
Mine is in a window, center of the pain. Field of view is from +40 to -40 Pan wise. Any more than that and I start to see the window frame on the sides of the video. If I do it, I think I’ll go with 10 or maybe even 5 degree increments. I’m using 1280 by 720 resolution on my camera. The specs for the Pi Foundation camera are 1080P@30 or 720P@60 FPS.

Right now I have the PTH on a Pi 4 and I have to say that the system’s response is very impressive. The video is very smooth at 1024x768. I’ll try the higher res.
I think you can adjust the range-of-travel from this line in each axis by changing the values in this line in each command:
if newPos >= 80: newPos = 80

This code finally makes the PTH useful to me. I’m so happy. :)

My Pan tilt is on a 3A+. I have 4 motion eye setups on 3A+'s. It makes for a nice small setup. It was also a nice cost saving over a 3B+. I don’t need the extra ports etc.
I only have the 1 Pi 4B and have other plans for that Pi.
On my 3A+ I found the Pan Tilt Hat a bit too close to my heatsink. I put mine on a booster header and tall 16mm standoffs. No worries of any of my wires touching the heat sink and maybe shorting out or something. How hot does your Pi 4 get? Passive cooling, heatsink or fan attached?

Some time today I’m going to have a good look see at that Pan Tilt Code. I would like to swap in my Preset code so I only have to do the one clip and past.
Then maybe look at the actual Pan Tilt part, edit that and try it out.

I have one ME camera, static, as my bird-cam. That’s on my original 3B. The 4 is my “developer” machine (although I’m hardly a developer). I have the PT on a GPIO riser. Then I double-sticky taped the fan right onto the SoC heatsink. Temps are around 38-42. Reasonable. Power for the fan comes from the light power pins under the PH board. I hot glued the servo wires to the board so they don’t interfere with the fan.

I know you’re better with code than I am (I’m much better with hardware) so you won’t have any problem adapting it. Knowing that it already works is a good place to start. ;)

My 4B is in a Pibow Coupe case with the matching Pimoroni wide flat heatsink. The I have a fanshim soldered to a booster header. I lowered the fan a little in its holder by leaving out the spacer nuts. My temps are right around 35 c as I type this from it. It has three of my cammera feds open in browser tabs, On top of the fan shim I soldered a Pico Hat Hacker. The booster header pins are nice an long so double stacking is easy. On the other side of the Pico hat hacker is a 90 male header with a Blinkt on it. Its showing CPU load. With the 90 male header its pointing forward instead of straight up. And facing me for easy viewing.

I did all the code mods, haven’t tested it yet though. I have one file with my three presets in it, and another file with the Pan Tilt code setup how i want it. I’ll likely test one or both of them before the weeks out. other things on the go at the moment.

Forgot to mention, I cut my servo cables. I shortened them to just what was needed for full movement and soldered them to the Pan tilt Hat. I removed the male headers and soldered the wires right to the pads on the hat. I also swapped out the 6 inch camera ribbon cable for an 8 inch one. With my hat raised the stock camera cable was a little too tight for my liking.

Not a bad idea to shorten the servo cables. I put the 8" video cable on too. I have the standard Pi case. I’m looking for a hat case for it but the only one I saw is expensive. The more i use the Pi 4 the more I’m amazed at its capabilities.

This Pi 4 will be going in a SmartiPi V2 case, along with a new 7 inch touch screen. Just waiting fore the parcel to arrive to put it all together. I’ll assemble it and make sure it all works then box it up to go under the tree. At some point I’ll be getting another Pi 4 to tinker with, might be a while though. Maybe my birthday in February?
The Coupe cases are good for putting a hat on top, its just not enclosed. I’ve put a Pibow Difusser on top of a few hats etc. I like the black Ninja ones. I just use the long Pibow bolt packs. Its better than no protection at all.

Yes, I may get one of the Coupe cases.

If your attaching a camera, connect the ribbon cable to the Pi before you secure the case with the nuts and bolts. About my only complaint with those cases is its hard to undo / open the CSI and DSI locking bars once the case in on and filly assembled. You can do it with a pin or needle, carefully, but its a lot easier if you just attach the cables to the Pi first.

Probably going to install and test my pan tilt code today. It should have no effect on my Presets even if it fails. I took the one preset he had in there out, the one he user to reset the pan tilt to 0,0. I set my pan limits at +40 to -40 and my moves to 2. I probably should have went with 5 but we’ll see. Its 6AM here right now and dark so I’ll wait until after my morning walk with my dog to try it. Sun will be up then and I’ll be able to see whats going on on the camera.

ssh into rpi and run these to create files and set permisions:

I am interested to install “Added Support for pimoroni’s pantilthat”. Unfortunately and honestly I must admit I don’t understand how to implement this code in my MoEye already running on my RPi4. I dont understand the first part starting mkdir… until the section starting import time. Or can I just copy paste the complete set over to my RPi4.
I need more specific guidance, please advice

Yes, the case is a bit too “basic” for my taste but I found a tool to pop the connector if necessary. I have a tool for everything. :)

The script may mess with your presets so check after you run it. I accidentally ran it twice and all the commands were messed up. I had to re-flash the ME install.