Browse Source

Remove prefixes from enum variants

pull/65/head
Steve Cook 2 years ago
parent
commit
9b5f5a09c8
  1. 43
      ctru-rs/examples/camera-image.rs
  2. 186
      ctru-rs/src/services/cam.rs

43
ctru-rs/examples/camera-image.rs

@ -33,28 +33,28 @@ fn main() {
let mut cam = Cam::init().expect("Failed to initialize CAM service."); let mut cam = Cam::init().expect("Failed to initialize CAM service.");
cam.set_size( cam.set_size(
CamSelect::SELECT_OUT1_OUT2, CamSelect::OUT1_OUT2,
CamSize::SIZE_CTR_TOP_LCD, CamSize::CTR_TOP_LCD,
CamContext::CONTEXT_A, CamContext::A,
) )
.expect("Failed to set camera size"); .expect("Failed to set camera size");
cam.set_output_format( cam.set_output_format(
CamSelect::SELECT_OUT1_OUT2, CamSelect::OUT1_OUT2,
CamOutputFormat::OUTPUT_RGB_565, CamOutputFormat::RGB_565,
CamContext::CONTEXT_A, CamContext::A,
) )
.expect("Failed to set camera output format"); .expect("Failed to set camera output format");
cam.set_noise_filter(CamSelect::SELECT_OUT1_OUT2, true) cam.set_noise_filter(CamSelect::OUT1_OUT2, true)
.expect("Failed to enable noise filter"); .expect("Failed to enable noise filter");
cam.set_auto_exposure(CamSelect::SELECT_OUT1_OUT2, true) cam.set_auto_exposure(CamSelect::OUT1_OUT2, true)
.expect("Failed to enable auto exposure"); .expect("Failed to enable auto exposure");
cam.set_auto_white_balance(CamSelect::SELECT_OUT1_OUT2, true) cam.set_auto_white_balance(CamSelect::OUT1_OUT2, true)
.expect("Failed to enable auto white balance"); .expect("Failed to enable auto white balance");
cam.set_trimming(CamPort::PORT_CAM1, false) cam.set_trimming(CamPort::CAM1, false)
.expect("Failed to disable trimming for Cam Port 1"); .expect("Failed to disable trimming for Cam Port 1");
cam.set_trimming(CamPort::PORT_CAM2, false) cam.set_trimming(CamPort::CAM2, false)
.expect("Failed to disable trimming for Cam Port 2"); .expect("Failed to disable trimming for Cam Port 2");
let mut buf = [0u8; BUF_SIZE]; let mut buf = [0u8; BUF_SIZE];
@ -76,9 +76,6 @@ fn main() {
if keys_down.bits() & KeyPad::KEY_R.bits() != 0 { if keys_down.bits() & KeyPad::KEY_R.bits() != 0 {
println!("Capturing new image"); println!("Capturing new image");
gfx.flush_buffers();
gfx.swap_buffers();
gfx.wait_for_vblank();
take_picture(&mut cam, &mut buf); take_picture(&mut cam, &mut buf);
} }
@ -103,28 +100,28 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) {
.get_max_bytes(WIDTH, HEIGHT) .get_max_bytes(WIDTH, HEIGHT)
.expect("Failed to get max bytes"); .expect("Failed to get max bytes");
cam.set_transfer_bytes(CamPort::PORT_BOTH, buf_size, WIDTH, HEIGHT) cam.set_transfer_bytes(CamPort::BOTH, buf_size, WIDTH, HEIGHT)
.expect("Failed to set transfer bytes"); .expect("Failed to set transfer bytes");
cam.activate(CamSelect::SELECT_OUT1_OUT2) cam.activate(CamSelect::OUT1_OUT2)
.expect("Failed to activate camera"); .expect("Failed to activate camera");
cam.clear_buffer(CamPort::PORT_BOTH) cam.clear_buffer(CamPort::BOTH)
.expect("Failed to clear buffer"); .expect("Failed to clear buffer");
cam.synchronize_vsync_timing(CamSelect::SELECT_OUT1, CamSelect::SELECT_OUT2) cam.synchronize_vsync_timing(CamSelect::OUT1, CamSelect::OUT2)
.expect("Failed to sync vsync timings"); .expect("Failed to sync vsync timings");
cam.start_capture(CamPort::PORT_BOTH) cam.start_capture(CamPort::BOTH)
.expect("Failed to start capture"); .expect("Failed to start capture");
let receive_event = cam let receive_event = cam
.set_receiving(buf, CamPort::PORT_CAM1, SCREEN_SIZE, buf_size as i16) .set_receiving(buf, CamPort::CAM1, SCREEN_SIZE, buf_size as i16)
.expect("Failed to set receiving"); .expect("Failed to set receiving");
let receive_event2 = cam let receive_event2 = cam
.set_receiving( .set_receiving(
&mut buf[SCREEN_SIZE as usize..], &mut buf[SCREEN_SIZE as usize..],
CamPort::PORT_CAM2, CamPort::CAM2,
SCREEN_SIZE, SCREEN_SIZE,
buf_size as i16, buf_size as i16,
) )
@ -141,7 +138,7 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) {
} }
}; };
cam.play_shutter_sound(CamShutterSoundType::SHUTTER_SOUND_TYPE_NORMAL) cam.play_shutter_sound(CamShutterSoundType::NORMAL)
.expect("Failed to play shutter sound"); .expect("Failed to play shutter sound");
unsafe { unsafe {
@ -155,7 +152,7 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) {
} }
}; };
cam.activate(CamSelect::SELECT_NONE) cam.activate(CamSelect::NONE)
.expect("Failed to deactivate camera"); .expect("Failed to deactivate camera");
} }

186
ctru-rs/src/services/cam.rs

@ -6,172 +6,172 @@ pub struct Cam(());
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamPort: u32 { pub struct CamPort: u32 {
const PORT_NONE = ctru_sys::PORT_NONE; const NONE = ctru_sys::PORT_NONE;
const PORT_CAM1 = ctru_sys::PORT_CAM1; const CAM1 = ctru_sys::PORT_CAM1;
const PORT_CAM2 = ctru_sys::PORT_CAM2; const CAM2 = ctru_sys::PORT_CAM2;
const PORT_BOTH = ctru_sys::PORT_BOTH; const BOTH = ctru_sys::PORT_BOTH;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamSelect: u32 { pub struct CamSelect: u32 {
const SELECT_NONE = ctru_sys::SELECT_NONE; const NONE = ctru_sys::SELECT_NONE;
const SELECT_OUT1 = ctru_sys::SELECT_OUT1; const OUT1 = ctru_sys::SELECT_OUT1;
const SELECT_IN1 = ctru_sys::SELECT_IN1; const IN1 = ctru_sys::SELECT_IN1;
const SELECT_OUT2 = ctru_sys::SELECT_OUT2; const OUT2 = ctru_sys::SELECT_OUT2;
const SELECT_IN1_OUT1 = ctru_sys::SELECT_IN1_OUT1; const IN1_OUT1 = ctru_sys::SELECT_IN1_OUT1;
const SELECT_OUT1_OUT2 = ctru_sys::SELECT_OUT1_OUT2; const OUT1_OUT2 = ctru_sys::SELECT_OUT1_OUT2;
const SELECT_IN1_OUT2 = ctru_sys::SELECT_IN1_OUT2; const IN1_OUT2 = ctru_sys::SELECT_IN1_OUT2;
const SELECT_ALL = ctru_sys::SELECT_ALL; const ALL = ctru_sys::SELECT_ALL;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamContext: u32 { pub struct CamContext: u32 {
const CONTEXT_NONE = ctru_sys::CONTEXT_NONE; const NONE = ctru_sys::CONTEXT_NONE;
const CONTEXT_A = ctru_sys::CONTEXT_A; const A = ctru_sys::CONTEXT_A;
const CONTEXT_B = ctru_sys::CONTEXT_B; const B = ctru_sys::CONTEXT_B;
const CONTEXT_BOTH = ctru_sys::CONTEXT_BOTH; const BOTH = ctru_sys::CONTEXT_BOTH;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamFlip: u32 { pub struct CamFlip: u32 {
const FLIP_NONE = ctru_sys::FLIP_NONE; const NONE = ctru_sys::FLIP_NONE;
const FLIP_HORIZONTAL = ctru_sys::FLIP_HORIZONTAL; const HORIZONTAL = ctru_sys::FLIP_HORIZONTAL;
const FLIP_VERTICAL = ctru_sys::FLIP_VERTICAL; const VERTICAL = ctru_sys::FLIP_VERTICAL;
const FLIP_REVERSE = ctru_sys::FLIP_REVERSE; const REVERSE = ctru_sys::FLIP_REVERSE;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamSize: u32 { pub struct CamSize: u32 {
const SIZE_VGA = ctru_sys::SIZE_VGA; const VGA = ctru_sys::SIZE_VGA;
const SIZE_QVGA = ctru_sys::SIZE_QVGA; const QVGA = ctru_sys::SIZE_QVGA;
const SIZE_QQVGA = ctru_sys::SIZE_QQVGA; const QQVGA = ctru_sys::SIZE_QQVGA;
const SIZE_CIF = ctru_sys::SIZE_CIF; const CIF = ctru_sys::SIZE_CIF;
const SIZE_QCIF = ctru_sys::SIZE_QCIF; const QCIF = ctru_sys::SIZE_QCIF;
const SIZE_DS_LCD = ctru_sys::SIZE_DS_LCD; const DS_LCD = ctru_sys::SIZE_DS_LCD;
const SIZE_DS_LCD_X4 = ctru_sys::SIZE_DS_LCDx4; const DS_LCD_X4 = ctru_sys::SIZE_DS_LCDx4;
const SIZE_CTR_TOP_LCD = ctru_sys::SIZE_CTR_TOP_LCD; const CTR_TOP_LCD = ctru_sys::SIZE_CTR_TOP_LCD;
const SIZE_CTR_BOTTOM_LCD = ctru_sys::SIZE_CTR_BOTTOM_LCD; const CTR_BOTTOM_LCD = ctru_sys::SIZE_CTR_BOTTOM_LCD;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamFrameRate: u32 { pub struct CamFrameRate: u32 {
const FRAME_RATE_15 = ctru_sys::FRAME_RATE_15; const RATE_15 = ctru_sys::FRAME_RATE_15;
const FRAME_RATE_15_TO_5 = ctru_sys::FRAME_RATE_15_TO_5; const RATE_15_TO_5 = ctru_sys::FRAME_RATE_15_TO_5;
const FRAME_RATE_15_TO_2 = ctru_sys::FRAME_RATE_15_TO_2; const RATE_15_TO_2 = ctru_sys::FRAME_RATE_15_TO_2;
const FRAME_RATE_10 = ctru_sys::FRAME_RATE_10; const RATE_10 = ctru_sys::FRAME_RATE_10;
const FRAME_RATE_8_5 = ctru_sys::FRAME_RATE_8_5; const RATE_8_5 = ctru_sys::FRAME_RATE_8_5;
const FRAME_RATE_5 = ctru_sys::FRAME_RATE_5; const RATE_5 = ctru_sys::FRAME_RATE_5;
const FRAME_RATE_20 = ctru_sys::FRAME_RATE_20; const RATE_20 = ctru_sys::FRAME_RATE_20;
const FRAME_RATE_20_TO_5 = ctru_sys::FRAME_RATE_20_TO_5; const RATE_20_TO_5 = ctru_sys::FRAME_RATE_20_TO_5;
const FRAME_RATE_30 = ctru_sys::FRAME_RATE_30; const RATE_30 = ctru_sys::FRAME_RATE_30;
const FRAME_RATE_30_TO_5 = ctru_sys::FRAME_RATE_30_TO_5; const RATE_30_TO_5 = ctru_sys::FRAME_RATE_30_TO_5;
const FRAME_RATE_15_TO_10 = ctru_sys::FRAME_RATE_15_TO_10; const RATE_15_TO_10 = ctru_sys::FRAME_RATE_15_TO_10;
const FRAME_RATE_20_TO_10 = ctru_sys::FRAME_RATE_20_TO_10; const RATE_20_TO_10 = ctru_sys::FRAME_RATE_20_TO_10;
const FRAME_RATE_30_TO_10 = ctru_sys::FRAME_RATE_30_TO_10; const RATE_30_TO_10 = ctru_sys::FRAME_RATE_30_TO_10;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamWhiteBalance: u32 { pub struct CamWhiteBalance: u32 {
const WHITE_BALANCE_AUTO = ctru_sys::WHITE_BALANCE_AUTO; const AUTO = ctru_sys::WHITE_BALANCE_AUTO;
const WHITE_BALANCE_3200K = ctru_sys::WHITE_BALANCE_3200K; const BALANCE_3200K = ctru_sys::WHITE_BALANCE_3200K;
const WHITE_BALANCE_4150K = ctru_sys::WHITE_BALANCE_4150K; const BALANCE_4150K = ctru_sys::WHITE_BALANCE_4150K;
const WHITE_BALANCE_5200K = ctru_sys::WHITE_BALANCE_5200K; const BALANCE_5200K = ctru_sys::WHITE_BALANCE_5200K;
const WHITE_BALANCE_6000K = ctru_sys::WHITE_BALANCE_6000K; const BALANCE_6000K = ctru_sys::WHITE_BALANCE_6000K;
const WHITE_BALANCE_7000K = ctru_sys::WHITE_BALANCE_7000K; const BALANCE_7000K = ctru_sys::WHITE_BALANCE_7000K;
const WHITE_BALANCE_NORMAL = ctru_sys::WHITE_BALANCE_NORMAL; const NORMAL = ctru_sys::WHITE_BALANCE_NORMAL;
const WHITE_BALANCE_TUNGSTEN = ctru_sys::WHITE_BALANCE_TUNGSTEN; const TUNGSTEN = ctru_sys::WHITE_BALANCE_TUNGSTEN;
const WHITE_BALANCE_WHITE_FLUORESCENT_LIGHT = ctru_sys::WHITE_BALANCE_WHITE_FLUORESCENT_LIGHT; const WHITE_FLUORESCENT_LIGHT = ctru_sys::WHITE_BALANCE_WHITE_FLUORESCENT_LIGHT;
const WHITE_BALANCE_DAYLIGHT = ctru_sys::WHITE_BALANCE_DAYLIGHT; const DAYLIGHT = ctru_sys::WHITE_BALANCE_DAYLIGHT;
const WHITE_BALANCE_CLOUDY = ctru_sys::WHITE_BALANCE_CLOUDY; const CLOUDY = ctru_sys::WHITE_BALANCE_CLOUDY;
const WHITE_BALANCE_HORIZON = ctru_sys::WHITE_BALANCE_HORIZON; const HORIZON = ctru_sys::WHITE_BALANCE_HORIZON;
const WHITE_BALANCE_SHADE = ctru_sys::WHITE_BALANCE_SHADE; const SHADE = ctru_sys::WHITE_BALANCE_SHADE;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamPhotoMode: u32 { pub struct CamPhotoMode: u32 {
const PHOTO_MODE_NORMAL = ctru_sys::PHOTO_MODE_NORMAL; const NORMAL = ctru_sys::PHOTO_MODE_NORMAL;
const PHOTO_MODE_PORTRAIT = ctru_sys::PHOTO_MODE_PORTRAIT; const PORTRAIT = ctru_sys::PHOTO_MODE_PORTRAIT;
const PHOTO_MODE_LANDSCAPE = ctru_sys::PHOTO_MODE_LANDSCAPE; const LANDSCAPE = ctru_sys::PHOTO_MODE_LANDSCAPE;
const PHOTO_MODE_NIGHTVIEW = ctru_sys::PHOTO_MODE_NIGHTVIEW; const NIGHTVIEW = ctru_sys::PHOTO_MODE_NIGHTVIEW;
const PHOTO_MODE_LETTER = ctru_sys::PHOTO_MODE_LETTER; const LETTER = ctru_sys::PHOTO_MODE_LETTER;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamEffect: u32 { pub struct CamEffect: u32 {
const EFFECT_NONE = ctru_sys::EFFECT_NONE; const NONE = ctru_sys::EFFECT_NONE;
const EFFECT_MONO = ctru_sys::EFFECT_MONO; const MONO = ctru_sys::EFFECT_MONO;
const EFFECT_SEPIA = ctru_sys::EFFECT_SEPIA; const SEPIA = ctru_sys::EFFECT_SEPIA;
const EFFECT_NEGATIVE = ctru_sys::EFFECT_NEGATIVE; const NEGATIVE = ctru_sys::EFFECT_NEGATIVE;
const EFFECT_NEGAFILM = ctru_sys::EFFECT_NEGAFILM; const NEGAFILM = ctru_sys::EFFECT_NEGAFILM;
const EFFECT_SEPIA01 = ctru_sys::EFFECT_SEPIA01; const SEPIA01 = ctru_sys::EFFECT_SEPIA01;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamContrast: u32 { pub struct CamContrast: u32 {
const CONTRAST_PATTERN_01 = ctru_sys::CONTRAST_PATTERN_01; const PATTERN_01 = ctru_sys::CONTRAST_PATTERN_01;
const CONTRAST_PATTERN_02 = ctru_sys::CONTRAST_PATTERN_02; const PATTERN_02 = ctru_sys::CONTRAST_PATTERN_02;
const CONTRAST_PATTERN_03 = ctru_sys::CONTRAST_PATTERN_03; const PATTERN_03 = ctru_sys::CONTRAST_PATTERN_03;
const CONTRAST_PATTERN_04 = ctru_sys::CONTRAST_PATTERN_04; const PATTERN_04 = ctru_sys::CONTRAST_PATTERN_04;
const CONTRAST_PATTERN_05 = ctru_sys::CONTRAST_PATTERN_05; const PATTERN_05 = ctru_sys::CONTRAST_PATTERN_05;
const CONTRAST_PATTERN_06 = ctru_sys::CONTRAST_PATTERN_06; const PATTERN_06 = ctru_sys::CONTRAST_PATTERN_06;
const CONTRAST_PATTERN_07 = ctru_sys::CONTRAST_PATTERN_07; const PATTERN_07 = ctru_sys::CONTRAST_PATTERN_07;
const CONTRAST_PATTERN_08 = ctru_sys::CONTRAST_PATTERN_08; const PATTERN_08 = ctru_sys::CONTRAST_PATTERN_08;
const CONTRAST_PATTERN_09 = ctru_sys::CONTRAST_PATTERN_09; const PATTERN_09 = ctru_sys::CONTRAST_PATTERN_09;
const CONTRAST_PATTERN_10 = ctru_sys::CONTRAST_PATTERN_10; const PATTERN_10 = ctru_sys::CONTRAST_PATTERN_10;
const CONTRAST_PATTERN_11 = ctru_sys::CONTRAST_PATTERN_11; const PATTERN_11 = ctru_sys::CONTRAST_PATTERN_11;
const CONTRAST_LOW = ctru_sys::CONTRAST_LOW; const LOW = ctru_sys::CONTRAST_LOW;
const CONTRAST_NORMAL = ctru_sys::CONTRAST_NORMAL; const NORMAL = ctru_sys::CONTRAST_NORMAL;
const CONTRAST_HIGH = ctru_sys::CONTRAST_HIGH; const HIGH = ctru_sys::CONTRAST_HIGH;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamLensCorrection: u32 { pub struct CamLensCorrection: u32 {
const LENS_CORRECTION_OFF = ctru_sys::LENS_CORRECTION_OFF; const OFF = ctru_sys::LENS_CORRECTION_OFF;
const LENS_CORRECTION_ON_70 = ctru_sys::LENS_CORRECTION_ON_70; const ON_70 = ctru_sys::LENS_CORRECTION_ON_70;
const LENS_CORRECTION_ON_90 = ctru_sys::LENS_CORRECTION_ON_90; const ON_90 = ctru_sys::LENS_CORRECTION_ON_90;
const LENS_CORRECTION_DARK = ctru_sys::LENS_CORRECTION_DARK; const DARK = ctru_sys::LENS_CORRECTION_DARK;
const LENS_CORRECTION_NORMAL = ctru_sys::LENS_CORRECTION_NORMAL; const NORMAL = ctru_sys::LENS_CORRECTION_NORMAL;
const LENS_CORRECTION_BRIGHT = ctru_sys::LENS_CORRECTION_BRIGHT; const BRIGHT = ctru_sys::LENS_CORRECTION_BRIGHT;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamOutputFormat: u32 { pub struct CamOutputFormat: u32 {
const OUTPUT_YUV_422 = ctru_sys::OUTPUT_YUV_422; const YUV_422 = ctru_sys::OUTPUT_YUV_422;
const OUTPUT_RGB_565 = ctru_sys::OUTPUT_RGB_565; const RGB_565 = ctru_sys::OUTPUT_RGB_565;
} }
} }
bitflags! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamShutterSoundType: u32 { pub struct CamShutterSoundType: u32 {
const SHUTTER_SOUND_TYPE_NORMAL = ctru_sys::SHUTTER_SOUND_TYPE_NORMAL; const NORMAL = ctru_sys::SHUTTER_SOUND_TYPE_NORMAL;
const SHUTTER_SOUND_TYPE_MOVIE = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE; const MOVIE = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE;
const SHUTTER_SOUND_TYPE_MOVIE_END = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE_END; const MOVIE_END = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE_END;
} }
} }

Loading…
Cancel
Save