Files
allwpilib/simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp

30 lines
1.0 KiB
C++
Raw Normal View History

/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "PrintPWM.h"
#include <iostream>
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "MockData/PWMData.h"
static void PWMCallback(const char* name, void* param,
const struct HAL_Value* value) {
auto pwm = static_cast<PrintPWM*>(param);
pwm->Publish(value->data.v_double);
}
PrintPWM::PrintPWM(int port) {
m_port = port;
HALSIM_RegisterPWMSpeedCallback(port, PWMCallback, this, false);
}
void PrintPWM::Publish(double value) {
std::cout << "PWM " << m_port << ": " << value << std::endl;
}