module GoPro.Command.DEVCString where import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BC import qualified Data.Map.Strict as Map import Data.Foldable (toList) import GoPro.DEVC import GoPro.GPMF fourcc :: FourCC -> BL.ByteString fourcc :: FourCC -> ByteString fourcc (FourCC (Char a,Char b,Char c,Char d)) = ByteString "4cc:" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> [Char] -> ByteString BC.pack [Char a,Char b,Char c,Char d] cval :: Value -> BL.ByteString cval :: Value -> ByteString cval (GFourCC FourCC f) = FourCC -> ByteString fourcc FourCC f cval Value x = Value -> ByteString forall a. Show a => a -> ByteString tshow Value x showValues :: Int -> [Value] -> BL.ByteString showValues :: Int -> [Value] -> ByteString showValues Int n = (Value -> ByteString) -> [Value] -> ByteString forall (f :: * -> *) a. Foldable f => (a -> ByteString) -> f a -> ByteString joinMap Value -> ByteString showValue where showValue :: Value -> ByteString showValue (GNested (FourCC, [Value]) x) = Int -> (FourCC, [Value]) -> ByteString showTelemetry (Int n Int -> Int -> Int forall a. Num a => a -> a -> a + Int 2) (FourCC, [Value]) x showValue (GFourCC FourCC f) = ([Char] -> ByteString BC.pack ([Char] -> ByteString) -> [Char] -> ByteString forall a b. (a -> b) -> a -> b $ Int -> Char -> [Char] forall a. Int -> a -> [a] replicate Int n Char ' ') ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> FourCC -> ByteString fourcc FourCC f showValue (GComplex [Char] f [Value] v) = ([Char] -> ByteString BC.pack ([Char] -> ByteString) -> [Char] -> ByteString forall a b. (a -> b) -> a -> b $ Int -> Char -> [Char] forall a. Int -> a -> [a] replicate Int n Char ' ') ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "Complex: " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> [Char] -> ByteString BC.pack [Char] f ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString ": " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString -> [ByteString] -> ByteString BL.intercalate ByteString ", " ((Value -> ByteString) -> [Value] -> [ByteString] forall a b. (a -> b) -> [a] -> [b] map Value -> ByteString cval [Value] v) showValue Value x = ([Char] -> ByteString BC.pack ([Char] -> ByteString) -> [Char] -> ByteString forall a b. (a -> b) -> a -> b $ Int -> Char -> [Char] forall a. Int -> a -> [a] replicate Int n Char ' ') ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Value -> ByteString forall a. Show a => a -> ByteString tshow Value x showTelemetry :: Int -> (FourCC, [Value]) -> BL.ByteString showTelemetry :: Int -> (FourCC, [Value]) -> ByteString showTelemetry Int n (FourCC (Char a,Char b,Char c,Char d),[Value] vs) = ([Char] -> ByteString BC.pack ([Char] -> ByteString) -> [Char] -> ByteString forall a b. (a -> b) -> a -> b $ (Int -> Char -> [Char] forall a. Int -> a -> [a] replicate Int n Char ' ') [Char] -> [Char] -> [Char] forall a. Semigroup a => a -> a -> a <> [Char a,Char b,Char c,Char d]) ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "\n" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> [Value] -> ByteString showValues (Int nInt -> Int -> Int forall a. Num a => a -> a -> a +Int 2) [Value] vs tshow :: Show a => a -> BL.ByteString tshow :: a -> ByteString tshow = [Char] -> ByteString BC.pack ([Char] -> ByteString) -> (a -> [Char]) -> a -> ByteString forall b c a. (b -> c) -> (a -> b) -> a -> c . a -> [Char] forall a. Show a => a -> [Char] show joinMap :: Foldable f => (a -> BL.ByteString) -> f a -> BL.ByteString joinMap :: (a -> ByteString) -> f a -> ByteString joinMap a -> ByteString f = ByteString -> [ByteString] -> ByteString BL.intercalate ByteString "\n" ([ByteString] -> ByteString) -> (f a -> [ByteString]) -> f a -> ByteString forall b c a. (b -> c) -> (a -> b) -> a -> c . (a -> ByteString) -> [a] -> [ByteString] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap a -> ByteString f ([a] -> [ByteString]) -> (f a -> [a]) -> f a -> [ByteString] forall b c a. (b -> c) -> (a -> b) -> a -> c . f a -> [a] forall (t :: * -> *) a. Foldable t => t a -> [a] toList showDEVC :: DEVC -> BL.ByteString showDEVC :: DEVC -> ByteString showDEVC DEVC{Int [Char] Map [Char] Telemetry _dev_telems :: DEVC -> Map [Char] Telemetry _dev_name :: DEVC -> [Char] _dev_id :: DEVC -> Int _dev_telems :: Map [Char] Telemetry _dev_name :: [Char] _dev_id :: Int ..} = ByteString "Device " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> ByteString forall a. Show a => a -> ByteString tshow Int _dev_id ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString ": " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> [Char] -> ByteString BC.pack [Char] _dev_name ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "\n" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> (Telemetry -> ByteString) -> Map [Char] Telemetry -> ByteString forall (f :: * -> *) a. Foldable f => (a -> ByteString) -> f a -> ByteString joinMap Telemetry -> ByteString showT Map [Char] Telemetry _dev_telems where showT :: Telemetry -> ByteString showT Telemetry{Int [Char] Word64 TVals _tele_values :: Telemetry -> TVals _tele_name :: Telemetry -> [Char] _tele_tsmp :: Telemetry -> Int _tele_stmp :: Telemetry -> Word64 _tele_values :: TVals _tele_name :: [Char] _tele_tsmp :: Int _tele_stmp :: Word64 ..} = ByteString " " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> [Char] -> ByteString BC.pack [Char] _tele_name ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " - stmp:" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Word64 -> ByteString forall a. Show a => a -> ByteString tshow Word64 _tele_stmp ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " tsmp:" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> ByteString forall a. Show a => a -> ByteString tshow Int _tele_tsmp ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "\n" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> TVals -> ByteString showTVal TVals _tele_values showTVal :: TVals -> ByteString showTVal (TVUnknown [Value] vals) = ByteString " Unknown type\n" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> [Value] -> ByteString showValues Int 6 [Value] vals showTVal (TVAccl Accelerometer{Float [(Float, Float, Float)] _acc_vals :: Accelerometer -> [(Float, Float, Float)] _acc_temp :: Accelerometer -> Float _acc_vals :: [(Float, Float, Float)] _acc_temp :: Float ..}) = ByteString " Temp: " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Float -> ByteString forall a. Show a => a -> ByteString tshow Float _acc_temp ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " and " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> ByteString forall a. Show a => a -> ByteString tshow ([(Float, Float, Float)] -> Int forall (t :: * -> *) a. Foldable t => t a -> Int length [(Float, Float, Float)] _acc_vals) ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " values like " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ((Float, Float, Float) -> ByteString forall a. Show a => a -> ByteString tshow((Float, Float, Float) -> ByteString) -> ([(Float, Float, Float)] -> (Float, Float, Float)) -> [(Float, Float, Float)] -> ByteString forall b c a. (b -> c) -> (a -> b) -> a -> c .[(Float, Float, Float)] -> (Float, Float, Float) forall a. [a] -> a head) [(Float, Float, Float)] _acc_vals showTVal (TVGyro Gyroscope{Float [(Float, Float, Float)] _gyro_vals :: Gyroscope -> [(Float, Float, Float)] _gyro_temp :: Gyroscope -> Float _gyro_vals :: [(Float, Float, Float)] _gyro_temp :: Float ..}) = ByteString " Temp: " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Float -> ByteString forall a. Show a => a -> ByteString tshow Float _gyro_temp ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " and " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> ByteString forall a. Show a => a -> ByteString tshow ([(Float, Float, Float)] -> Int forall (t :: * -> *) a. Foldable t => t a -> Int length [(Float, Float, Float)] _gyro_vals) ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " values like " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ((Float, Float, Float) -> ByteString forall a. Show a => a -> ByteString tshow((Float, Float, Float) -> ByteString) -> ([(Float, Float, Float)] -> (Float, Float, Float)) -> [(Float, Float, Float)] -> ByteString forall b c a. (b -> c) -> (a -> b) -> a -> c .[(Float, Float, Float)] -> (Float, Float, Float) forall a. [a] -> a head) [(Float, Float, Float)] _gyro_vals showTVal (TVFaces [Face] fs) = ByteString " Faces:" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> (if [Face] -> Bool forall (t :: * -> *) a. Foldable t => t a -> Bool null [Face] fs then ByteString "" else ByteString "\n") ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> (Face -> ByteString) -> [Face] -> ByteString forall (f :: * -> *) a. Foldable f => (a -> ByteString) -> f a -> ByteString joinMap ((\Face{Float Int _face_smile :: Face -> Float _face_h :: Face -> Float _face_w :: Face -> Float _face_y :: Face -> Float _face_x :: Face -> Float _face_id :: Face -> Int _face_smile :: Float _face_h :: Float _face_w :: Float _face_y :: Float _face_x :: Float _face_id :: Int ..} -> ByteString " " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Float -> ByteString forall a. Show a => a -> ByteString tshow Float _face_x ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "x" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Float -> ByteString forall a. Show a => a -> ByteString tshow Float _face_y ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString ", " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Float -> ByteString forall a. Show a => a -> ByteString tshow Float _face_w ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "x" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Float -> ByteString forall a. Show a => a -> ByteString tshow Float _face_h ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString ", smile=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Float -> ByteString forall a. Show a => a -> ByteString tshow Float _face_smile)) [Face] fs showTVal (TVGPS GPS{Int [GPSReading] UTCTime _gps_readings :: GPS -> [GPSReading] _gps_time :: GPS -> UTCTime _gps_p :: GPS -> Int _gps_readings :: [GPSReading] _gps_time :: UTCTime _gps_p :: Int ..}) = ByteString " GPS time=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> UTCTime -> ByteString forall a. Show a => a -> ByteString tshow UTCTime _gps_time ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " p=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> ByteString forall a. Show a => a -> ByteString tshow Int _gps_p ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString ", len(rs)=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> ByteString forall a. Show a => a -> ByteString tshow ([GPSReading] -> Int forall (t :: * -> *) a. Foldable t => t a -> Int length [GPSReading] _gps_readings) ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "\n hd=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> GPSReading -> ByteString showGPS ([GPSReading] -> GPSReading forall a. [a] -> a head [GPSReading] _gps_readings) showTVal (TVScene [Map Location Float] ss) = ByteString " Scenes, found " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Int -> ByteString forall a. Show a => a -> ByteString tshow ([Map Location Float] -> Int forall (t :: * -> *) a. Foldable t => t a -> Int length [Map Location Float] ss) ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString ", first:\n" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ((Location, Float) -> ByteString) -> [(Location, Float)] -> ByteString forall (f :: * -> *) a. Foldable f => (a -> ByteString) -> f a -> ByteString joinMap ((\(Location k,Float v) -> ByteString " " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Location -> ByteString forall a. Show a => a -> ByteString tshow Location k ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Float -> ByteString forall a. Show a => a -> ByteString tshow Float v)) (Map Location Float -> [(Location, Float)] forall k a. Map k a -> [(k, a)] Map.assocs ([Map Location Float] -> Map Location Float forall a. [a] -> a head [Map Location Float] ss)) showTVal (TVAudioLevel AudioLevel{[Int] _audio_peak :: AudioLevel -> [Int] _audio_rms :: AudioLevel -> [Int] _audio_peak :: [Int] _audio_rms :: [Int] ..}) = ByteString " Audio levels:\n" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " rms: " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ([Int] -> ByteString forall a. Show a => a -> ByteString tshow [Int] _audio_rms) ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "\n" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " peak: " ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ([Int] -> ByteString forall a. Show a => a -> ByteString tshow [Int] _audio_peak) showGPS :: GPSReading -> BL.ByteString showGPS :: GPSReading -> ByteString showGPS GPSReading{Double _gpsr_speed3d :: GPSReading -> Double _gpsr_speed2d :: GPSReading -> Double _gpsr_alt :: GPSReading -> Double _gpsr_lon :: GPSReading -> Double _gpsr_lat :: GPSReading -> Double _gpsr_speed3d :: Double _gpsr_speed2d :: Double _gpsr_alt :: Double _gpsr_lon :: Double _gpsr_lat :: Double ..} = ByteString "(" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Double -> ByteString forall a. Show a => a -> ByteString tshow Double _gpsr_lat ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString "," ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Double -> ByteString forall a. Show a => a -> ByteString tshow Double _gpsr_lon ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString ") alt=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Double -> ByteString forall a. Show a => a -> ByteString tshow Double _gpsr_alt ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " spd2d=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Double -> ByteString forall a. Show a => a -> ByteString tshow Double _gpsr_speed2d ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> ByteString " spd3d=" ByteString -> ByteString -> ByteString forall a. Semigroup a => a -> a -> a <> Double -> ByteString forall a. Show a => a -> ByteString tshow Double _gpsr_speed3d