fix(agb02): joystick on 0-255
This commit is contained in:
parent
5bbc38c6ca
commit
5f779aef09
2 changed files with 20 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
||||||
{ config, pkgs, lib, modulesPath, ... }:
|
{ config, pkgs, lib, modulesPath, ... }:
|
||||||
|
let
|
||||||
|
agb-control-box = pkgs.callPackage ./agb { };
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
"${modulesPath}/installer/sd-card/sd-image-aarch64.nix"
|
"${modulesPath}/installer/sd-card/sd-image-aarch64.nix"
|
||||||
|
@ -17,9 +19,18 @@
|
||||||
networking.networkmanager.enable = true;
|
networking.networkmanager.enable = true;
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
(pkgs.callPackage ./agb {})
|
agb-control-box
|
||||||
pkgs.libgpiod
|
pkgs.libgpiod
|
||||||
];
|
];
|
||||||
|
|
||||||
|
systemd.services."agb-control-box" = {
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
unitConfig.Description = "The program of the control-box";
|
||||||
|
serviceConfig = {
|
||||||
|
Restart = "always";
|
||||||
|
ExecStart = "${agb-control-box}/bin/agb /dev/gpiochip0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
system.stateVersion = "24.11";
|
system.stateVersion = "24.11";
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ constexpr std::chrono::microseconds poll_period = 5ms;
|
||||||
constexpr std::chrono::microseconds server_ratelimit = 50ms;
|
constexpr std::chrono::microseconds server_ratelimit = 50ms;
|
||||||
constexpr std::chrono::microseconds retry_timeout = 500ms;
|
constexpr std::chrono::microseconds retry_timeout = 500ms;
|
||||||
|
|
||||||
constexpr std::pair<double, double> joystick_movement(1.0, 1.0);
|
constexpr std::pair<double, double> joystick_movement(.3, .3);
|
||||||
|
|
||||||
const gpiod::line::offsets drive_down = { 21, 13, 6 };
|
const gpiod::line::offsets drive_down = { 21, 13, 6 };
|
||||||
|
|
||||||
|
@ -119,8 +119,11 @@ int main(const int argc, char const* const* const argv) {
|
||||||
if(bool(joystick_read[3])) spot_pos.second -= joystick_movement.second;
|
if(bool(joystick_read[3])) spot_pos.second -= joystick_movement.second;
|
||||||
|
|
||||||
if (bool(joystick_read[0]) || bool(joystick_read[1])
|
if (bool(joystick_read[0]) || bool(joystick_read[1])
|
||||||
|| bool(joystick_read[2]) || bool(joystick_read[3]))
|
|| bool(joystick_read[2]) || bool(joystick_read[3])){
|
||||||
|
spot_pos.first = std::clamp(spot_pos.first, 0.0, 255.0);
|
||||||
|
spot_pos.second = std::clamp(spot_pos.second, 0.0, 255.0);
|
||||||
has_changed = true;
|
has_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// Buttons ///
|
/// Buttons ///
|
||||||
bool pressed = bool(line_reader.get_value(black_button));
|
bool pressed = bool(line_reader.get_value(black_button));
|
||||||
|
@ -164,8 +167,8 @@ int main(const int argc, char const* const* const argv) {
|
||||||
"\"whiteButton\": {},"
|
"\"whiteButton\": {},"
|
||||||
"\"blackButton\": {}"
|
"\"blackButton\": {}"
|
||||||
"}}\n",
|
"}}\n",
|
||||||
spot_pos.first,
|
uint8_t(spot_pos.first),
|
||||||
spot_pos.second,
|
uint8_t(spot_pos.second),
|
||||||
int(decoder_pos),
|
int(decoder_pos),
|
||||||
white_pressed,
|
white_pressed,
|
||||||
black_pressed
|
black_pressed
|
||||||
|
|
Loading…
Reference in a new issue