Browse Source

Cargo fmt

pull/65/head
Steve Cook 2 years ago
parent
commit
2405754d1b
  1. 19
      ctru-rs/examples/camera-image.rs
  2. 75
      ctru-rs/src/services/cam.rs

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

@ -107,7 +107,8 @@ fn main() { @@ -107,7 +107,8 @@ fn main() {
}
fn take_picture(cam: &mut Cam, buf: &mut [u8]) {
let buf_size = cam.get_max_bytes(WIDTH as i16, HEIGHT as i16)
let buf_size = cam
.get_max_bytes(WIDTH as i16, HEIGHT as i16)
.expect("Failed to get max bytes");
cam.set_transfer_bytes(CamPort::PORT_BOTH, buf_size, WIDTH as i16, HEIGHT as i16)
@ -116,7 +117,6 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) { @@ -116,7 +117,6 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) {
cam.activate(CamSelect::SELECT_OUT1_OUT2)
.expect("Failed to activate camera");
cam.clear_buffer(CamPort::PORT_BOTH)
.expect("Failed to clear buffer");
cam.synchronize_vsync_timing(CamSelect::SELECT_OUT1, CamSelect::SELECT_OUT2)
@ -125,15 +125,12 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) { @@ -125,15 +125,12 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) {
cam.start_capture(CamPort::PORT_BOTH)
.expect("Failed to start capture");
let receive_event = cam.set_receiving(
buf,
CamPort::PORT_CAM1,
SCREEN_SIZE as u32,
buf_size as i16,
)
let receive_event = cam
.set_receiving(buf, CamPort::PORT_CAM1, SCREEN_SIZE as u32, buf_size as i16)
.expect("Failed to set receiving");
let receive_event2 = cam.set_receiving(
let receive_event2 = cam
.set_receiving(
&mut buf[SCREEN_SIZE..],
CamPort::PORT_CAM2,
SCREEN_SIZE as u32,
@ -172,14 +169,14 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) { @@ -172,14 +169,14 @@ fn take_picture(cam: &mut Cam, buf: &mut [u8]) {
fn write_picture_to_frame_buffer_rgb_565(
fb: RawFrameBuffer,
img: &mut [u8],
img: &[u8],
x: u16,
y: u16,
width: u16,
height: u16,
) {
let fb_8 = fb.ptr;
let img_16 = img.as_mut_ptr() as *mut u16;
let img_16 = img.as_ptr() as *const u16;
let mut draw_x;
let mut draw_y;
for j in 0..height {

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

@ -266,10 +266,7 @@ impl Cam { @@ -266,10 +266,7 @@ impl Cam {
}
}
pub fn get_buffer_error_interrupt_event(
&self,
port: CamPort,
) -> crate::Result<u32> {
pub fn get_buffer_error_interrupt_event(&self, port: CamPort) -> crate::Result<u32> {
unsafe {
let mut event: Handle = 0;
let r = ctru_sys::CAMU_GetBufferErrorInterruptEvent(&mut event, port.bits());
@ -305,10 +302,7 @@ impl Cam { @@ -305,10 +302,7 @@ impl Cam {
}
}
pub fn is_finished_receiving(
&self,
port: CamPort,
) -> crate::Result<bool> {
pub fn is_finished_receiving(&self, port: CamPort) -> crate::Result<bool> {
unsafe {
let mut finished_receiving = false;
let r = ctru_sys::CAMU_IsFinishedReceiving(&mut finished_receiving, port.bits());
@ -419,7 +413,13 @@ impl Cam { @@ -419,7 +413,13 @@ impl Cam {
params: CamTrimmingParams,
) -> crate::Result<()> {
unsafe {
let r = ctru_sys::CAMU_SetTrimmingParams(port.bits(), params.x_start, params.y_start, params.x_end, params.y_end);
let r = ctru_sys::CAMU_SetTrimmingParams(
port.bits(),
params.x_start,
params.y_start,
params.x_end,
params.y_end,
);
if r < 0 {
Err(r.into())
} else {
@ -428,16 +428,19 @@ impl Cam { @@ -428,16 +428,19 @@ impl Cam {
}
}
pub fn get_trimming_params(
&self,
port: CamPort,
) -> crate::Result<CamTrimmingParams> {
pub fn get_trimming_params(&self, port: CamPort) -> crate::Result<CamTrimmingParams> {
unsafe {
let mut x_start = 0;
let mut y_start = 0;
let mut x_end = 0;
let mut y_end = 0;
let r = ctru_sys::CAMU_GetTrimmingParams(&mut x_start, &mut y_start, &mut x_end, &mut y_end, port.bits());
let r = ctru_sys::CAMU_GetTrimmingParams(
&mut x_start,
&mut y_start,
&mut x_end,
&mut y_end,
port.bits(),
);
if r < 0 {
Err(r.into())
} else {
@ -445,7 +448,7 @@ impl Cam { @@ -445,7 +448,7 @@ impl Cam {
x_start,
y_start,
x_end,
y_end
y_end,
})
}
}
@ -561,10 +564,7 @@ impl Cam { @@ -561,10 +564,7 @@ impl Cam {
}
}
pub fn is_auto_exposure(
&self,
camera: CamSelect,
) -> crate::Result<bool> {
pub fn is_auto_exposure(&self, camera: CamSelect) -> crate::Result<bool> {
unsafe {
let mut is_auto_exposure = false;
let r = ctru_sys::CAMU_IsAutoExposure(&mut is_auto_exposure, camera.bits());
@ -587,10 +587,7 @@ impl Cam { @@ -587,10 +587,7 @@ impl Cam {
}
}
pub fn is_auto_white_balance(
&self,
camera: CamSelect,
) -> crate::Result<bool> {
pub fn is_auto_white_balance(&self, camera: CamSelect) -> crate::Result<bool> {
unsafe {
let mut is_auto_white_balance = false;
let r = ctru_sys::CAMU_IsAutoWhiteBalance(&mut is_auto_white_balance, camera.bits());
@ -806,11 +803,7 @@ impl Cam { @@ -806,11 +803,7 @@ impl Cam {
}
}
pub fn get_latest_vsync_timing(
&self,
port: CamPort,
past: u32,
) -> crate::Result<i64> {
pub fn get_latest_vsync_timing(&self, port: CamPort, past: u32) -> crate::Result<i64> {
let mut timing = 0;
unsafe {
let r = ctru_sys::CAMU_GetLatestVsyncTiming(&mut timing, port.bits(), past);
@ -849,11 +842,7 @@ impl Cam { @@ -849,11 +842,7 @@ impl Cam {
}
}
pub fn read_register_i2c_exclusive(
&self,
camera: CamSelect,
addr: u16,
) -> crate::Result<u16> {
pub fn read_register_i2c_exclusive(&self, camera: CamSelect, addr: u16) -> crate::Result<u16> {
unsafe {
let mut data = 0;
let r = ctru_sys::CAMU_ReadRegisterI2cExclusive(&mut data, camera.bits(), addr);
@ -881,7 +870,10 @@ impl Cam { @@ -881,7 +870,10 @@ impl Cam {
}
}
pub fn set_image_quality_calibration_data(&self, data: ImageQualityCalibrationData) -> crate::Result<()> {
pub fn set_image_quality_calibration_data(
&self,
data: ImageQualityCalibrationData,
) -> crate::Result<()> {
unsafe {
let r = ctru_sys::CAMU_SetImageQualityCalibrationData(data.0);
if r < 0 {
@ -904,7 +896,10 @@ impl Cam { @@ -904,7 +896,10 @@ impl Cam {
}
}
pub fn set_package_parameter_without_context(&self, param: PackageParameterCameraSelect) -> crate::Result<()> {
pub fn set_package_parameter_without_context(
&self,
param: PackageParameterCameraSelect,
) -> crate::Result<()> {
unsafe {
let r = ctru_sys::CAMU_SetPackageParameterWithoutContext(param.0);
if r < 0 {
@ -915,7 +910,10 @@ impl Cam { @@ -915,7 +910,10 @@ impl Cam {
}
}
pub fn set_package_parameter_with_context(&self, param: PackageParameterContext) -> crate::Result<()> {
pub fn set_package_parameter_with_context(
&self,
param: PackageParameterContext,
) -> crate::Result<()> {
unsafe {
let r = ctru_sys::CAMU_SetPackageParameterWithContext(param.0);
if r < 0 {
@ -926,7 +924,10 @@ impl Cam { @@ -926,7 +924,10 @@ impl Cam {
}
}
pub fn set_package_parameter_with_context_detail(&self, param: PackageParameterContextDetail) -> crate::Result<()> {
pub fn set_package_parameter_with_context_detail(
&self,
param: PackageParameterContextDetail,
) -> crate::Result<()> {
unsafe {
let r = ctru_sys::CAMU_SetPackageParameterWithContextDetail(param.0);
if r < 0 {

Loading…
Cancel
Save