From 78cea261bb42434c73e27ef0081683219f141895 Mon Sep 17 00:00:00 2001 From: Wei Shuai Date: Sat, 20 Jan 2018 21:28:29 +0800 Subject: tracker/wii: update according to Issue: #718 suggestion from sthalik 1. fix horizon line drawing 2. fix copyright 3. optimize pointer mangement 4. reduce wii led power consumption --- tracker-pt/tracker-wii/wii_camera.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'tracker-pt/tracker-wii/wii_camera.cpp') diff --git a/tracker-pt/tracker-wii/wii_camera.cpp b/tracker-pt/tracker-wii/wii_camera.cpp index 21ff998d..514c71ae 100644 --- a/tracker-pt/tracker-wii/wii_camera.cpp +++ b/tracker-pt/tracker-wii/wii_camera.cpp @@ -1,11 +1,10 @@ -/* Copyright (c) 2012 Patrick Ruoff - * Copyright (c) 2015-2016 Stanislaw Halik - * Copyright (c) 2017-2018 Wei Shuai - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ +/* +* Copyright (c) 2017-2018 Wei Shuai +* +* Permission to use, copy, modify, and/or distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +*/ #include "wii_camera.h" @@ -77,8 +76,8 @@ WIICamera::result WIICamera::get_frame(pt_frame& frame_) pt_camera_open_status WIICamera::start(int idx, int fps, int res_x, int res_y) { - m_pDev = new wiimote; - if (m_pDev == NULL) + m_pDev = std::make_unique(); + if (!m_pDev) { stop(); return cam_open_error; @@ -97,7 +96,7 @@ void WIICamera::stop() m_pDev->Disconnect(); Beep(1000, 200); if (m_pDev) { - delete m_pDev; + m_pDev=nullptr; m_pDev = NULL; } @@ -140,6 +139,7 @@ bool WIICamera::_get_points(struct wii_info& wii) { bool dot_sizes = (m_pDev->IR.Mode == wiimote_state::ir::EXTENDED); bool ret = false; + int point_count = 0; for (unsigned index = 0; index < 4; index++) { @@ -153,6 +153,7 @@ bool WIICamera::_get_points(struct wii_info& wii) wii.Points[index].isize = 1; } wii.Points[index].bvis = dot.bVisible; + point_count++; ret = true; } else { wii.Points[index].ux = 0; @@ -161,6 +162,7 @@ bool WIICamera::_get_points(struct wii_info& wii) wii.Points[index].bvis = dot.bVisible; } } + m_pDev->SetLEDs(3 - point_count); return ret; } -- cgit v1.2.3