How do I use the pyb-library in WiPy? The documentation is incomplete. import pyb doesn't work. Also not from pyb import delay or something. Also machine hasn't delay in it. How do I use following code?
https://docs.micropython.org/en/latest/pyboard/library/pyb.html#pyb.delay
easiest way to put a delay in micropython is
import time
time.sleep(Nseconds)
time.sleep_ms(N_milliseconds)
FYI:
pyb library is a module specific for pyboard, will not work in WiPy or ESP32 default micropython firmware. Basically the firmware for pyboard has a module called pyb along with other micropython standard modules. you could always add different modules and build a custom firmware and flash your WiPy.
Related
I'm trying to learn to write Hardware Abstraction Layer (HAL).
Here's the path I've taken so far, please correct me if I'm off in any step.
Downloaded AOSP and built it successfully (86%)
Located Vehicle Hal Support Library
Located android.hardware.automotive.vehicle C++ code.
Things I've attempted after that the steps below without succeeding to get those above classes recognized.
Import android.hardware.automotive.vehicle classes in Android Studio for a typical Android App that targets 29 Api Level.
Adding meta tag of android.car app
Copy/Pasting all source code under AOSP /packages/services/Car/
Partially contemplated adding android.hardware.automotive.vehicle#2.0.so Library and trying to access it through JNI (Not so sure about this one).
Please orient me, I see some repositories on github not doing anything special and somehow they're able to import the package in a java class like this.
import android.hardware.automotive.vehicle.V2_0.VehicleHwKeyInputAction;
import android.hardware.automotive.vehicle.V2_0.VehiclePropValue;
import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyAccess;
Here
how on earth do they get access to those classes?
Thanks
Vehicle HAL is not meant to be accessed directly from apps. Car Service does that for you.
You have couple options depending on what you're actually trying to accomplish:
Learn to write HAL services - it's like writing a driver for a given hardware (in this case, something that provides car data to Car Service).
Learn to write HAL clients - try modifying EmbeddedKitchenSink app first. Please note you need to build it with AOSP and not in AmdroidStudio since this is a system app (and regular apps doesn't have access to the HAL)
Learn Vehicle APIs - that's what you need car lib for. Details on how to use it: https://stackoverflow.com/a/63321234/14759774
Hello i can't find out how i can add the Esp32 Wifi Library (https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi) to my PlatformIO Project (VS-Code). How am I able to add and import it?
I tried to copy it into the libs folder, and add the link to lib_deps
And Stackoverflow just says this Problem is not described good enough... Sorry for the lines at the end
You don't need to explicitly add the Wifi library. It's part of the ESP32 Arduino Core support.
You do need a correctly written platformio.ini file for that to work. That file would look something like this:
[env: esp32dev]
platform = espressif32
framework = arduino
board = esp32dev
lib_deps = ...
Where you would replace esp32dev with the correct name for the board you're using.
If you don't have framework set to arduino, PlatformIO won't load the Arduino Core and you won't have the wifi library available.
I developed a script to set attributes for my iTunes music library on my Mac using an Apple Script bridge called AppScript. AppScript Allowed me to write my code in native Python without having to learn Apple Script. AppSript would translate my native Python to Apple Script. Since Apple Script has been replaced with Swift I am wondering if there is a similar bridge for Swift. I have done my research, but no luck. Additionally if there is, can you provide an example of how to control iTunes(now Music) with said library? Thanks in advance
Swift is designed to use MacOS's programming APIs: AppKit, Quartz, CoreFoundation, NSObject, etc, rather than the higher level OSAX event-driven elements (open, print, close, document, window, etc) used in AppleScript.
The system-bundled python (2.7) comes with pyObjC, which allows python to use the same programming APIs that Swift does, e.g. "writing apps". PyObjC also contains a Scripting Bridge to the AppleScript events and objects. The canonical example code does use iTunes:
from Foundation import *
from ScriptingBridge import *
iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
print iTunes.currentTrack().name()
(Obvs, this is python2 and you need to put brackets round the print command. Also, personally, I wouldn't import * everything, as it's very slow.)
Here are some other methods/attributes based on the Script Dictionary:
iTunes.nextTrack()
iTunes.previousTrack()
iTunes.playpause()
iTunes.fastForward()
iTunes.setShuffleEnabled_(False)
iTunes.currentPlaylist().playOnce_(False)
The system-bundled version of pyObjC is very old, but the library itself is still being developed. If you're using python3, then you should install the latest version of pyObjC.
FWIW, you can actually run uncompiled Swift as a 'script' in the shell.
I want two scripts integrate in to one script.
Scripts for sensors SHT10 and MAX31855. Both make use of software SPI.
The SHT10 use GPIO.BOARD and the MAX31855 use GPIO.BCM.
The problem is that I get an error "ValueError: A different mode is already been set." I don't know how to resolve this because both sensors used different libraries. I think that the problem is in those libraries.
Is there an easy solution for this problem.
Running the scripts separately than there is no problem
You can try using GPIO.setmode(GPIO.BCM) and then in the other program using GPIO.setmode(GPIO.BOARD).
I would like to get a list of the built-in a(and frozen) modules using micropython, running on the board (ESP32) itself.
help('modules') will give you a list of all modules, but this is only send to the terminal. I have not been able to capture it on any other way.
also see micropython forum where the only option seems to be to use dupterm
which unfortunately is not available on ESP32