mpu-6050 degrees

Hi guys,
I'm trying to use a mpu-6050 accelerometer/gyroscope for a segway and I've got some values coming out of it using a basic complimentary filter but these values aren't in a 0-360 degree format. I want to get a 0-360 degree value from it but I'm not sure how to.

Here's my code:

#include<Wire.h>

#define DT 0.01
#define AA 0.98

#define A_GAIN 0.0573
#define G_GAIN 0.00875

#define MAX_ANGLE 30.0

float angle_pitch = 0.0;
float rate_pitch = 0.0;

signed int accel_y_zero = 0;
signed int gyro_y_zero = 0;

const int MPU=0x68;  // I2C address of the MPU-6050
int16_t AcY,GyY;
void setup(){
  
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
}

void loop(){
  signed int a_pitch = 0;
  signed int g_pitch = 0;
  signed int vref = 0;
    
  float pitch_error = 0.0;
  float angle = 0.0;
      
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,14,true);  // request a total of 14 registers
  AcY=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)     
  GyY=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  
  a_pitch = (accel_y_zero - AcY);
  g_pitch = (GyY - gyro_y_zero); 

  rate_pitch = (float) g_pitch * G_GAIN;

  angle = (AA)*(angle + rate_pitch *DT) + (0.02) * (a_pitch); //this is my attempt of the complementary filter
    
  Serial.print (" | a_pitch = "); Serial.print (a_pitch);
  Serial.print (" | g_pitch = "); Serial.print (g_pitch);
  Serial.print (" | angle = "); Serial.println(angle); 
  delay (500);
}

So what its doing is giving me a value of 330 for the peak so when the mpu-6050 is pointing up, a 0 when the mpu-6050 is flat and a -330 value when the mpu-6050 is pointing down. I want to use a 0-360 degree value from this code but I'm not sure how to get there.
I've just started looking at the complimentary filter so I'm not sure if I've got that quite right part of it quite right yet.

I've written some of the code myself but some of it is from some websites and some of it is from other libraries such as the <Wire.h> library which is the library for the mpu-6050.

Any help will be appreciated!
Thanks,
nathman11

Wire.requestFrom(MPU,14,true);  // request a total of 14 registers
  AcY=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)     
  GyY=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)

I doubt you are reading the device correctly. The above requests data from 14 registers, but you read only four. Also, the variable names are inappropriate, which will confuse you and everyone else.

You are not applying the sensor offset corrections consistently.

You should make sure you know how to get the correct data, in units that make sense to you, from all axes before attempting to implement a complementary filter.